Notes on the Linux operating system
Last Updated 2018-11-16
HOME directory
.local/share/Trash/files/ # deleted files are moved here automatically
Important directories
/ # root directory or trunk
/bin/ # for essential executable binaries
# such as ps, ls, cp
# Note: there must be no subdirectories
/sbin/ # for essential binaries related to system administration
# such as fsck, shutdown
/dev/ # contains device nodes created by the udev system
/opt/ # optional application software packages
/proc/ # pseudo filesystems containing virtual files
# only existing in memory
/proc/<Process-ID-#>/ # contains vital information about a process
/proc/sys/ # contains information about te entire system
/var/ # (variable) contains files expected to change in
# size and content as the system is running
/var/log/ # system log files
/var/log/cups/ # log files for CUPS
/var/lib/ # packages and database files
/var/spool/ # print queues
/var/spool/cron/ # contains crontabs for all users
/var/spool/cups/ # job files (print queues) for CUPS
# data files are prefixed with d
# control files are prefixed with c
/var/tmp/ # temp files
/var/ftp/ # FTP service
/var/www/ # HTTP web service
/etc/ # system configuration files
/etc/sudoers.d/ # sudoers
/etc/network/ # basic network configuration files for Debian systems
/etc/sysconfig/network/
# basic network configuration files for Fedora and SUSE
/etc/cups/ # CUPS related configuration files
/etc/cups/ppd/ # printer drivers for CUPS
/boot/ # essential files needed to boot the system
/boot/grub/ # Grand Unified Bootloader (GRUB) files
# sometimes /boot/grub2/
/lib/ # contains libraries (common code shared by applications)
# for the essential programs in /bin/ and /sbin/
# dynamically loaded libraries OR Shared Objects (SO)
/lib/modules/<kernel-version-number>/
# kernel modules: kernel code, often device drivers,
# that can be loaded and unloaded
# without re-starting the system
/lib64/ # 64-bit libraries
/run/media/ or /media/ # for removable media
/mnt/ # temporarily mounting filesystems: network filesystems,
# temporary partitions, loopback filesystems
# (files which pretend to be partitions)
/sys/ # virtual pseudo-filesystem giving information
# about the system and the hardware.
# Can be used to alter system parameters and for debugging
/srv/ # site-specific data served up by the system. Seldom used.
/tmp/ # temporary files; on some distributions erased across
# a reboot and/or may actually be a ramdisk in memory
/usr/ # multi-user applications, utilities and data
/usr/include/ # header files used to compile applications
/usr/lib/ # libraries for programs in /usr/bin and /usr/sbin/
/usr/lib64/ # 64-bit libraries for 64-bit programs
/usr/bin/ # primary directory of executable commands on the system
/usr/sbin/ # non-essential system binaries, such as system daemons
/usr/share/ # shared data used by applications,
# generally architecture-independent
/usr/share/doc/ # contains package documentation
/usr/src/ # source code, usually for the Linux kernel
/usr/local/ # data and programs specific to the local machine
/root/ # home directory of the superuser account
Important files
/etc/X11/xorg.conf # configuration file for X server (CentOS)
/etc/ntp.conf # configuration file for Network Time Protocol (NTP)
/etc/resolv.conf # configuration file for host name to IP addr mappings (DNS)
/etc/crontab # configuration file for cron table
/etc/fstab # configuration file for filesystems (filesystem table)
/etc/sudoers # configuration file for sudo
/etc/cups/cupsd.conf# system-wide settings (e.g., network security) for CUPS
/etc/cups/printers.conf
# printer-specific settings
/etc/environment # list of environment variables available for all users
/etc/profile # system-wide configuration file for the Bourne shell
/etc/bash.bashrc # shell settings for all users
/etc/X11/default-display-manager
# default display manager used
/etc/exports # directories and permissions that
# a host is willing to share with other systems
/etc/passwd # contains user information
/etc/shadow # contains passwords in encrypted format
/etc/group # list of user groups and their members
/etc/hosts # list of hosts
/etc/shells # list of available shells
/etc/apt/sources.list # sources for apt-get
/etc/samba/smb.conf # samba file share configuration
/boot/vmlinuz # the compressed Linux kernel, required for booting
/boot/initramfs # the initial ram filesystem, required for booting
# sometimes called initrd instead
/boot/config # the kernel configuration file, for debugging & bookkeeping
/boot/System.map # kernel symbol table, for debugging
/proc/version # shows Linux version used
/proc/mounts # shows all mounted filesystems
/proc/cpuinfo # shows cpu information
/proc/interrupts # shows TODO
/proc/meminfo # shows physical RAM information
/proc/partitions # shows usage of all partitions
/proc/swaps # shows usage of swap partition or file
/dev/null # a pseudofile where data is discarded
# a.k.a. bit bucket, black hole
/dev/random # device node that draws on the entropy pool
# to provide random numbers;
# does not reuse internal pool
/dev/urandom # device node that reuses the internal pool to generate
# pseudorandom bits
/usr/share/dict/words OR /usr/dict/words
# a built-in list of words
~/.bash_profile OR ~/.bash_login OR ~/.profile
# possible configuration file for shell when logging in
~/.bashrc # configuration file for each new shell
~/.bash_aliases # aliases read by .bashrc
~/.bash_history # command line history from previous terminals
# commands are appended to this file upon terminal close
/var/log/auth.log # contains sudo commands and failures (Debian systems)
# /var/log/messages & /var/log/secure (other systems)
pwd/.gitignore # contain files for git to ignore
Keyboard Shortcuts
SUPER + L # lock screen
CTRL + ALT + L # lock screen
Power button + ALT # suspend (CentOS and SUSE)
ALT + F2 # run a command
CTRL + ALT + F1~F7 # virtual terminals 1~7 (VT 1~7)
# For graphical desktop (X),
# CentOS/RHEL and openSUSE uses VT 1,
# while Ubuntu uses VT 7
ALT + F1~F7 # switch between virtual terminals from one without X
CTRL + SHIFT + W # close window
CTRL + SHIFT + Q # quit program
Terminal Shortcuts
CTRL + L # clear the screen
CTRL + D # exit the current shell
CTRL + Z # suspend a foreground process
CTRL + C # terminate a foreground process
CTRL + A # go to the beginning of line
CTRL + E # go to the end of line
CTRL + H # works the same as backspace
CTRL + W # delete the word before the cursor
CTRL + U # delete from the beginning of line to cursor position
CTRL + R # search previously used commands
Command Shell choices
/bin/sh
/bin/bash # bash shell
/bin/tcsh
/bin/csh
/bin/ksh
/usr/bin/perl
/usr/bin/python
Applications
ntp # for syncing time with the Network Time Protocol
gnome-tweak-tool # for detailed settings such as Theme
dpkg # the underlying package manager for Debian systems
apt # Advanced Package Tool, the high-level package manager
# used by Debian systems
RPM # Red Hat Package Manager, the underlying package manager
# for Red Hat, openSUSE, Mandriva, CentOS, Oracle Linux
yum # Yellowdog Updater, Modified, the high-level package manager
# used by Fedora and Red Hat Enterprise Linux
dnf # another high-level package manager
# used by Fedora Family Linux
YaST # Yet another Setup Tool, the high-level package manager
# used by SUSE Family Linux
zypper # another high-level package manager
# used by SUSE Family Linux
PackageKit # package manager used by GNOME and Fedora
nmtui # simple graphical network manager
nmcli # command line network manager
lynx # configurabel text-based web browser
links OR elinks # based on lynx; can display tables and frames
w3m # another text-based web browser
mutt & mail # text mode email clients
Ekiga # Used to connect to Voice over Internet Protocols (VoIP) networks
Pidgin # Used to access GTalk, AIM, ICQ, MSN, IRC
Hexchat # Used to access Internet Relay Chat (IRC) networks
FFmpeg # record, convert and stream audio/video
GIMP # GNU Image Manipulation Program (similar to Adobe Photoshop)
eog # Eye of Gnome, an image viewer with slide show capability
Inkscape # an image editor similar to Adobe Illustrator
convert # part of (ImageMagick), a command line tool that can modify
# images in many ways
Scribus # used for creating documents used for publishing
info # GNU project's standard documentation format
# more free-form than man and supports linked sub-sections
# structure: node -> menus -> items
gnome-help OR yelp # graphical help system for GNOME
khelpcenter # graphical help system for KDE
nano # basic editor
gedit # basic graphical editor for GNOME
kwrite # basic graphical editor for KDE
kate # basic graphical editor for KDE
vi # advanced editor
vim # vi improved
vimtutor # tutorial for vi
gvim # graphical version of vim for GNOME
kvim # graphical version of vim for KDE
emacs # advanced editor
sed # stream editor
awk # powerful file and text-manipulation utility
# created by A. Aho, P. Weinberger & B. Kernighan
ftp # insecure command line ftp client
sftp # secure command line ftp client
# uses the ssh (Secure Shell) protocol
# does not work with anonymous ftp
ncftp
yafc # yet another FTP client
lsusb # manages common USB printers
lp # command-line printing utility for System V
lpr # command-line printing utility for BSD
enscript # converts text files to PostScript and other formats
ghostscript # includes gs, ps2pdf & pdf2ps
poppler # includes pstopdf & pdftops
ImageMagick # includes convert
Evince # most widely used Linux PDF reader
Okular # PDF reader available on a KDE environment
GhostView # open-source PDF reader
Xpdf # open-source PDF reader
pdftk # PDF Toolkit that can operate on PDF files
pdfinfo # extract information about PDF files
flpsed # add data to a PostScript document
pdfmod # graphical application for modifying PDF files
dos2unix # converts text files across different platforms
John The Ripper # automatically verifies whether passwords are strong enough
Compress files
gzip # the most frequently used Linux compression utility
bzip2 # produces files smaller than those produced by gzip
xz # the most space-efficient compression utility in Linux
zip # often needed to decompress from other operating systems
tar # group files into an archive and compress archive
File systems
ext4, btrfs, ext3, squashfs # supported by Linux
ntfs, vfat # Windows
hfs, hfs+ # MacOS
jfs # IBM
xfs # SGI
ext4, btrfs, jfs, xfs # journaling varieties
NFS # network filesystem
# , first developed by Sun Microsystems
CIFS (SAMBA) # developed by Microsoft
File Manager Shortcuts
CTRL + 1 # switch to Icon format
CTRL + 2 # switch to List format
CTRL + H # show/hide hidden files
CTRL + L # display current location
CTRL + R # reload
CTRL + + # zoom in
CTRL + - # zoom out
CTRL + 0 # normal size
F9 # show/hide side bar
CTRL + F # search bar
SHIFT + DELETE # permanently delete file
Processes
program # a series of instructions (binary data) for the CPU
# and possibly other resources (images, sound files
# and such) organised into a package
process # a running instance of a program
interactive processes
# need to be started by a user at the command line or GUI
# Example: bash, top
batch processes # automatic processes scheduled from and then
# disconnected from the terminal
# Example: updatedb
daemons # server processes that run continuously
# Example: httpd, xinetd, sshd
threads # light processes; tasks that run under
# an umbrella of a main process
# Example: gnome-terminal-server
kernel threads # kernel tasks that users have little control over
# Example: kthreadd, migration, ksoftirqd
scheduler # kernel function that constantly shifts processes
# on and off the CPU
run queue # for processes in a running state (need a time slice)
wait queue # for processes in a sleep state
zombie state # when a child process has completed but its
# parent process hasn't asked about it
PID # process ID number
PPID # parent process ID number; if parent dies,
# the adoptive parent is kthreadd with PPID = 2
TID # thread ID number; unique for each thread
# in a multi-thread process
RUID # Real User ID; the user who started the process
EUID # Effective User ID; access rights of the user
RGID # Real Group ID; the group that started the process
EGID # Effective Group ID; access rights of the group
nice value (niceness) # sets the priority of a process
# -20 is the highest priority; 19 is the lowest
load average # the average of the load number for a given period of time
# takes into account uninterruptible sleeping processes
# 3 numbers: last min, last 5 mins, last 15 mins
Important environmental variables (duplicated in shell_script_syntax.sh)
$USER # user name
$HOSTNAME # hostname of the machine
$SECONDS # the number of seconds since the shell/script was started
$LINENO # the current line number in the shell/script
$RANDOM # a random number from the Linux kernel's
# built-in random number generator,
# by the OpenSSL library function,
# using the FIPS140 algorithm
$HOME # home directory of current user
$PWD # present working directory
$PATH # ordered list of directories scanned upon command
$PS1 # the prompt statement
$SHELL # user's default command shell
$HISTFILE # the location of the history file
$HISTFILESIZE # the maximum number of lines in the history file
# (default 500)
$HISTSIZE # the maximum number of commands in the history file
$HISTCONTROL # how commands are stored (ignoreboth, ignordups)
$HISTIGNORE # which command lines can be unsaved
File Streams
stdin # standard input, file descriptor == 0
# absolute path: /proc/<processID>/fd/0
# relative path: /dev/stdin or /proc/self/fd/0
stdout # standard output, file descriptor == 1
# absolute path: /proc/<processID>/fd/1
# relative path: /dev/stdout or /proc/self/fd/1
stderr # standard error, file descriptor == 2
# absolute path: /proc/<processID>/fd/2
# relative path: /dev/stderr or /proc/self/fd/2
Network operations
IPv4 # Internet protocol version 4
# uses 32 bits for addresses
# only 4.3 billion unique addresses
IPv6 # Internet protocol version 6
# uses 128 bits for addresses
# only 3.4 x 10^38 billion unique addresses
IPv4
Class A # NetID.HostID.HostID.HostID
# A maximum of 126 such networks
# Each network has up to 16.7 million unique hosts
# Range: 1.0.0.0 to 127.255.255.255
Class B # NetID.NetID.HostID.HostID
# A maximum of 16,384 such networks
# Each network has up to 65,536 unique hosts
# Range: 128.0.0.0 to 191.255.255.255
Class C # NetID.NetID.NetID.HostID
# A maximum of 2.1 million such networks
# Each network has up to 256 unique hosts
# Range: 192.0.0.0 to 223.255.255.255
/etc/password file contents
username:password:UID:GID:User Info:Home Directory:Shell
username # Should be between 1~32 characters
password # x if encrypted
UID # 0 - root; 1-99 - other predefined accounts
# 100-999 - system accounts and groups
# 1000+ - normal users
GID # primary group ID, stored in the /etc/group file
User Info # (optional) allows insertion of extra information
Home Directory # absolute location of home directory
Shell # absolute location of default shell
Top output
us # percentage CPU time for users
sy # percentage CPU time for kernel (system)
ni # percentage of user jobs running at a low priority (niceness)
id # percentage CPU time in idle mode
wa # percentage of jobs waiting for input/output
hi # percentage of hardware interrupts
si # percentage of software interrupts
st # steal time
Swap # swap space: temporary storage space on the hard drive
VIRT # virtual memory
RES # physical memory
SHR # shared memory
S # status
TIME+ # execution time
Top single-letter commands
t # display or hide summary information
m # display or hide memory information
A # sort the process list by top resource consumers
r # renice a specific process
k # kill a specific process
f # enter the configuration screen
o # select a new sort order
Vim Command Mode commands
:help # open vim documentation
K # bring up manual page for a Unix command
h OR BACKSPACE # move left
l OR SPACE # move right
j # move down
k # move up
0 OR | # move to the start of line
^ OR _ # move to the start of line ignoring whitespace
n| # move to column n of current line
$ # move to the end of line
^ # move to the first non-blank character in the line
+ # move to the first character in the next line
- # move to the first non-blank character in the previous line
w # move to the start of the next word
W # move to the start of the next blank-delimited word
e # move to the end of the current word
E # move to the end of the current blank-delimited word
b # move to the beginning of the previous blank-delimited word
B # move to the beginning of the previous word
H # move to the top of the screen
nH # move to the nth line from top of the screen
M # move to the middle of the screen
nL # move to the nth line from the bottom of the screen
L # move to the bottom of the screen
gg OR :0 # move to the start of the file
G OR :$ # move to the bottom of the file
499G OR :499 # move to line 499
Fc # move back to c
fc # move forward to c
Tc # move back to just after c
tc # move forward to just before c
; # repeat last F, f, T, f command
, # repeat last F, f, T, f command in the reverse direction
( # move back one sentence
) # move forward one sentence
{ # move back one paragraph
} # move forward one paragraph
[[ # move back one section
]] # move forward one section
CTRL + u # move back half a screen
CTRL + d # move forward half a screen
CTRL + b # move back one screen
CTRL + f # move forward one screen
CTRL + l # to refresh and center screen
CTRL + e # move screen up one line
CTRL + y # move screen down one line
zt # move screen so that current line is at the top
zz # move screen so that current line is at the center
zb # move screen so that current line is at the bottom
mc # set a mark called c
`c # move to the mark called c
:= # show total number of lines
:.= # show current line number
CTRL + g # show location in file and the file status
/ # search in the forward direction
? # search in the backward direction
/WORD\c # search for WORD while ignoring case
n # move to next occurrence of search pattern
N # move to previous occurrence of search pattern
CTRL + o # move to older position
CTRL + i OR TAB # move to newer position
% # search for matching parenthesis
v # start visual selection
V # start visual selection of lines
CTRL + v # start visual selection of blocks
u # undo
U # undo entire line
CTRL + r # redo
>> # insert tab at start of line
<< # remove tab at start of line
4>> # insert tab at start of the following 4 lines
4<< # remove tab at start of the following 4 lines
i # (start Insert Mode) insert text before the cursor
I # (start Insert Mode) insert text at start of line
a # (start Insert Mode) append text after the cursor
A # (start Insert Mode) append text to end of line
o # (start Insert Mode) create new line below the cursor
O # (start Insert Mode) create new line above the cursor
rx # replace the character at the cursor with x
R # (start Replace Mode) replace text
cl OR s # (start Insert Mode) change this character
cw # (start Insert Mode) change until just before
# the start of the next word
ce # (start Insert Mode) change until the end of current word
c$ OR C # (start Insert Mode) change until the end of line
S # (start Insert Mode) change the entire line
~ # toggle upper/lower case
J # join lines
4J # join the next 4 lines together
x # delete character (Delete)
X # delete previous character (Backspace)
2x # delete 2 characters
dw # delete to just before the start of the next word
d2w # delete to just before the start of 2 words beyond
de # delete to the end of the current word
d$ OR D # delete to the end of line
dd # delete the entire line
2dd # delete two lines
:200,300d # delete lines 200 through 300
dG # delete to the end of file
yw # copy to just before the start of the next word
ye # copy to the end of the current word
y$ # copy to the end of line
yy OR :y # copy the entire line
"cy # yank buffered text in register c
p # paste buffered text after cursor
P # paste buffered text before cursor
. # repeat last text-changing command
"4p # retrieve the last 4th delete (up to 9th)
"cp # paste buffered text in register c
@: # repeat last command starting with :
:r FILENAME # read contents of FILENAME and place after cursor
:nr FILENAME # read contents of FILENAME and place after line n
:r !ls # read standard output of ls command
:s/old/new # substitute the first occurrence in the line
:s/old/new/g # substitute globally in the line
:499,502s/old/new/g # substitute globally between lines 499 and 502
:.,.+10s/old/new/g # substitute globally between the current line
# and 10 lines after
:%s/old/new/g # substitute globally in the file
:%s/old/new/gc # substitute globally in the file with prompt
& # repeat last :s command
:w FILENAME # save buffer to FILENAME
:'<,'>w TEST # save visually selected text to TEST
:q! OR ZQ # exit without saving
:wq OR :x OR ZZ # save and exit
:! # execute an external command
:! wc % # word count
:set ic # ignore upper/lower case when searching (ignorecase)
:set is # show partial matches for a search phrase (incsearch)
# "incremental searching"
:set hls # highlight all matching phrases (hlsearch)
:set noic # disable ignore case option
:set nocp # make sure vim is not in compatible mode
:N or :E # open a new split-screen window
CTRL + w, CTRL + w # jump from one window to another
:e ~/.vimrc # edit the vimrc file
:new # new file in vim
:r $VIMRUNTIME/vimrc_example.vim
# read in the example "vimrc" file contents
:sh # start shell (type exit to quit)
:autocmd Filetype txt setlocal tabstop=4 shiftwidth=4 expandtab
:w !sudo tee % # save as sudoer
Vim Line Mode Commands
% # current file name
CTRL + d # show a list of possible command completions
TAB # complete command
Vim Insert Mode Commands
ALT + [Normal Mode Key]
# exit Insert Mode and perform Normal Mode command
CTRL + c # exit Insert Mode
CTRL + [ # exit Insert Mode and finish abbreviations
CTRL + h # delete previous character
CTRL + w # delete previous word
CTRL + u # delete to start of line
CTRL + x # delete to start of inserted text
CTRL + v # take the next charater literally
CTRL + i # insert tab
emacs
CTRL + H, t # open emacs tutorial
CTRL + G # quit current command
CTRL + B # move cursor left
CTRL + F # move cursor right
CTRL + N # move cursor down
CTRL + P # move cursor up
ALT + B # move cursor to the previous word
ALT + F # move cursor to the next word
CTRL + A # move cursor to the start of line
CTRL + E # move cursor to the end of line
ALT + A # move cursor to the start of sentence
ALT + E # move cursor to the end of sentence
CTRL + V # move forward one page
ALT + V # move back one page
ALT + G + G, 499 # move to line 499
CTRL + L # to refresh and center screen
ALT + SHIFT + < # move to the start of the file
ALT + SHIFT + > # move to the bottom of the file
CTRL + U # add a numerical argument
CTRL + U, 8, * # type ********
CTRL + O # insert a blank line
CTRL + D # delete character
ALT + D # kill to the end of the current word
CTRL + K # kill to the end of line
ALT + K # kill to the end of sentence
CTRL + Y # paste killed text (yank)
ALT + Y # paste previously killed text
CTRL + SPACE # mark start of region, end will be cursor position
CTRL + W # kill marked region
CTRL + S # search in the forward direction
CTRL + R # search in the reverse direction
CTRL + X, 1 # close all other windows
CTRL + X, 2 # split windows
CTRL + O # move to other window
CTRL + X, F # set column width
CTRL + X, U OR CTRL + SHIFT + -
# undo
CTRL + X, I # read file and insert at current position
CTRL + X, CTRL + F # find file
CTRL + X, CTRL + B # list buffers
CTRL + X, B # switch buffer
CTRL + X, CTRL + S # save current file
CTRL + X, S # save all files
CTRL + X, CTRL + W # write to the file giving a new name when prompted
CTRL + X, CTRL + C # exit after being prompted to save files
cron
# Each line has 6 fields:
# * means all possible values
MIN # minutes (00 to 59)
HOUR # hours (00 to 23)
DOM # day of month (01-31)
MON # month field (01-12)
DOW # day of week (0-6, 0 is Sunday)
CMD # any command to be executed
Partitions
Control Groups (cgroups)
Linux Containers (LXC)
Virtualization
Other Acronyms
IMAP # Internet Message Access Protocol,
# used to access emails stored on a remote server
POP # Post Office Protocol,
# used to access emails stored on a remote server
DHCP # Dynamic Host Configuration Protocol
NIC # Network Interface Card (NIC)
FTP # File Transfer Protocol
DNS # Domain Name System
CUPS # Common UNIX Printing System
PDF # Portable Document Format
RTF # Rich Text Format
HTML # HyperText Markup Language
pts # pseudo terminal slave
SUID # Set owner User ID upon execution
SHA-512 # Secure Hashing Algorithm 512 bits
# used to encrypt passwords in the /etc/shadow file
PAM # Pluggable Authentication Modules
VPS # Virtual Private Server
API # Application Programming Interface
HTTP # HyperText Transfer Protocol
Web addresses
http://localhost:631/ # CUPS web interface
makefile format
[target]: [dependencies...]
[commands...]