Friday, April 20, 2018

How to get the list of manual installed software on Ubuntu, Debian

Using apt-mark:

comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)

Using aptitude:

comm -23 <(aptitude search '~i !~M' -F '%p' | sed "s/ *$//" | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)

How does it work
  1. Get the list of manually installed packages. For aptitude, the additional sed strips out remaining whitespace at the end of the line.
  2. Get the list of packages installed right after a fresh install.
  3. Compare the files, only output the lines in file 1 that are not present in file 2.
Other possibilities don't work as well:
  • Using the ubuntu-14.04-desktop-amd64.manifest file (here for Ubuntu 14.04) instead of /var/log/installer/initial-status.gz. More packages are shown as manually installed even though they are not.
  • Using apt-mark showauto instead of /var/log/installer/initial-status.gz. apt-mark for example doesn't include the xserver-xorg package, while the other file does.
Both list more packages than the above solution.


Friday, October 13, 2017

To copy and paste on Linux console screen (using screen)

$ screen

<CTRL A><CTRL C>     -  Create a new screen
<CTRL A><SPACE>       - Cycle to the next screen

To Copy and Paste
<CTRL A>[                      - Enter Mark mode.  Use VI navigation keys to move around screen.  Use <SPACE> or <ENTER> to mark the beginning and then the end of the block

<CTRL A>]                      - Paste selected text

Sunday, August 6, 2017

Command not found when using sudo

Give sudo your current PATH with:
sudo env "PATH=$PATH" your_command
 
 
Elaborating on @opyate's answer, I am using the following shell script (which may be named mysudo, for example):
#!/bin/bash
sudo -E env "PATH=$PATH" "$@"
  • -E tells sudo to preserve the environment.
  • env "PATH=$PATH" is expanded outside the sudo call, making the external PATH available inside the sudo too (this is required in addition to the -E as the PATH usually receives special treatment in addition to the treatment the entire environment receives).
  • "$@" passes the arguments our script receives to the sudo line.
Save the script in a file in a directory in the PATH, give it +x permissions, et voilĂ .
 
Since the current answers are a little vague, the specific setting in /etc/sudoers changing your path is secure_path:
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
You can modify it it with sudo visudo, or better yet, add the directories you need:
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
shareimprove this answer
 
 

Saturday, August 5, 2017

Run multiple command together

command1 && command2
    run command2 only if command1 is success

command1 || command2
    run command2 only if command1 failed.

command1 ; command2
    run command2 after command1 no matter what happen to command1



How to get System Information in Ubuntu

sudo lshw -short
sudo lshw -html >sysiinfo.html
lscpu lsblk lspci lsusb
dmidecode
sudo dmidecode -l memory
ex. memory, baseboard, bios, processor, chassis,

To add more desktops to Ubuntu

sudo apt install ubuntu-gnome-desktop

Choose lightdm
Logout and click on Ubuntu Logo
Choose gnome desktop

sudo apt install cinnamon-desktop-environment -y


Sunday, June 4, 2017

Fix "package is in a very bad inconsistent state" error

dpkg: error processing package libllvm4.0:i386 (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 libllvm4.0:i386
E: Sub-process /usr/bin/dpkg returned an error code (1)



sudo apt-get install -f --reinstall libllvm4.0:i386