My Linux tips and tricks page part 3.


My Linux tips and tricks page, Part 3.

Go to part 2.

How to list all processes spawned by a user.

The pstree [USERNAME] command will list all processes that belong to a user, e.g pstree user1 will show all processes that belong to the user user1.

Show detailed information about a package on a Debian system with the apt-cache command.

[jason@darknet:~] apt-cache show vim
Package: vim
Version: 2:7.4.1689-3
Installed-Size: 2293
Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
Architecture: amd64
Provides: editor
Depends: vim-common (= 2:7.4.1689-3), vim-runtime (= 2:7.4.1689-3), libacl1 (>= 2.2.51-8), libc6 (>= 2.15), libgpm2 (>= 1.20.4), libselinux1 (>= 1.32), libtinfo5 (>= 6)
Suggests: ctags, vim-doc, vim-scripts
Size: 997884
SHA256: 313f823fa5be4965667de40c490a47488d10b8e4deafb68b4d109e27b10fa9c6
SHA1: a6a7ac1c1134b18b08e964c10371a110742ce985
MD5sum: ef63a1fb6ff086d67a649679a94ea169
Description-en: Vi IMproved - enhanced vi editor
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 Many new features have been added: multi level undo, syntax
 highlighting, command line history, on-line help, filename
 completion, block operations, folding, Unicode support, etc.
 .
 This package contains a version of vim compiled with a rather
 standard set of features.  This package does not provide a GUI
 version of Vim.  See the other vim-* packages if you need more
 (or less).
Description-md5: 59e8b8f7757db8b53566d5d119872de8
Homepage: http://www.vim.org/
Tag: devel::editor, implemented-in::c, interface::commandline,
 interface::text-mode, role::program, scope::application,
 uitoolkit::ncurses, use::editing, works-with::text, works-with::unicode
Section: editors
Priority: optional
Filename: pool/main/v/vim/vim_7.4.1689-3_amd64.deb
 
Package: vim
Version: 2:7.4.488-7
Installed-Size: 2233
Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
Architecture: amd64
Provides: editor
Depends: vim-common (= 2:7.4.488-7), vim-runtime (= 2:7.4.488-7), libacl1 (>= 2.2.51-8), libc6 (>= 2.15), libgpm2 (>= 1.20.4), libselinux1 (>= 1.32), libtinfo5
Suggests: ctags, vim-doc, vim-scripts
Description-en: Vi IMproved - enhanced vi editor
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 Many new features have been added: multi level undo, syntax
 highlighting, command line history, on-line help, filename
 completion, block operations, folding, Unicode support, etc.
 .
 This package contains a version of vim compiled with a rather
 standard set of features.  This package does not provide a GUI
 version of Vim.  See the other vim-* packages if you need more
 (or less).
Description-md5: 59e8b8f7757db8b53566d5d119872de8
Homepage: http://www.vim.org/
Tag: devel::editor, implemented-in::c, interface::commandline,
 interface::text-mode, role::program, scope::application,
 uitoolkit::ncurses, use::editing, works-with::text, works-with::unicode
Section: editors
Priority: optional
Filename: pool/main/v/vim/vim_7.4.488-7_amd64.deb
Size: 952572
MD5sum: 838cf10277be8bd38d5f2d2b6ad93ad8
SHA1: b65076deb6c6b97d7e686deeba9e1859412af4ee
SHA256: 790f9760b098c444ce42393a11ff463210e8488b1d775240a5c1a564bd569388

This is very useful for learning about a package and what it does and provides when installed.

List the contents of an archive file with the lsar command.

[jason@darknet:~/Downloads] lsar VMMap.zip       
VMMap.zip: Zip
vmmap.exe
Vmmap.chm
Eula.txt

Capture packets from a network interface using the dumpcap command on Kali Linux.

[jason@darknet:~/Downloads] sudo dumpcap
[sudo] password for jason: 
Capturing on 'wlan0'
File: /tmp/wireshark_pcapng_wlan0_20160426110151_71jLzw
Packets captured: 25766
Packets received/dropped on interface 'wlan0': 25766/94 (pcap:94/dumpcap:0/flushed:0/ps_ifdrop:0) (99.6%)

This saves to a file all of the network packets captured on that interface.

Windows 10 bash shell is not very useful after all.

No meme face.
Just no.

The Windows 10 bash shell, supposedly an alternative to Ubuntu and Debian, offering a fully featured bash shell, but the networking does not work due to the fact the ICMP sockets are not yet implemented. And this is why the user cannot ping websites or use wget to download files. So, I will not be using it. Not a very impressive product from Microsoft after all.

That is why it is better to use Debian GNU/Linux or Ubuntu 16.04 on bare metal or a Virtual Machine. A bare metal Linux installation does support a very wide range of hardware and is very capable as a network file-server, SSH server and hosting a website on a port forwarded to your IP address. Software such as mpv for watching movies and video. Audacious for listening to MP3 music, and Firefox for browsing the web. The user is promised a very capable desktop when Ubuntu is installed, and Linux does deliver.

Setting up a Linux desktop is much easier than it was in the early days. Now everything works out of the box.

Game of Thrones series 6 in mpv player.
Game of Thrones series 6 in mpv player.

Windows 10 is quite resource hungry when running in a Virtual Machine. Far more so than Windows 7 or Ubuntu. I have no idea why this is so, I have a machine with 12 Gigabytes of RAM and I give 4 gigabytes to the VM, but it still runs poorly. Even with the VMware additions installed, it does not make the desktop run any better. I will stick with Windows 7 for running Windows applications, it is still supported until 2020, so no hurry to update to Windows 10. There is a way to disable the Windows 10 upgrade icon in Windows 7. That will take care of automatic upgrades to the new Windows 10 operating system. A few applications do not work properly on Windows 10. I will wait until Windows 10 service pack 1 before having another look at this operating system. I am not sure if the upcoming update will fix any of the problems. I am not sure why Microsoft had to release another OS instead of just fixing up Windows 7 and making it even better. Sites such as 4chan have countless shills that spruik the new OS as the second coming of Christ, but it is just a Windows operating system. Installing software with apt-get install works with the Windows 10 bash shell, but not much else. You cannot use the Lynx browser to read news on Slashdot or use wget to download a new kernel update and then build and install the kernel package and reboot into a new kernel version.

Colorize the output of Linux manual pages. A very useful bash function.

function man()
{
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}

Universal file extractor. Extract any compressed file with this handy script.

# extract: unified archive extractor
# usage: extract <file>
    extract ()
    {
      if [ -f $1 ] ; then
        case $1 in
          *.tar.bz2)   tar xjf $1   ;;
          *.tar.gz)    tar xzf $1   ;;
          *.bz2)       bunzip2 $1   ;;
          *.rar)       rar x $1     ;;
          *.gz)        gunzip $1    ;;
          *.tar)       tar xf $1    ;;
          *.tbz2)      tar xjf $1   ;;
          *.tgz)       tar xzf $1   ;;
          *.zip)       unzip $1     ;;
          *.Z)         uncompress $1;;
          *.7z)        7z x $1      ;;
          *.exe)       cabextract $1;;
          *)           echo "'$1' cannot be extracted via extract"; false ;;
        esac
      else
          'echo' -e "'$1' is not a valid file\nusage: extract <file>\n"
          false
      fi
    }