List of (Semi-)Common Linux Commands¶
Getting help (besides Googling):
man
: shows the manual pages of a command, use q to quit it, use / to go to search mode. After typing something to search for, press Enter and then use n (or N) to go to the next (or previous) occurrence.--help
: a flag for most commands, used to give a description of the command and its flags (e.g.touch --help
).
Basic navigation, file handling, and terminal usage:
pwd
: print name of current/working directory.ls
: list directory contents.ls -a
: also hidden files.cd
: change directory.mkdir
: make a new directory in current directory.rmdir
: remove empty directory .rm
: remove files.rm -r
: remove directory and the files contained in it (recursively).cp
: copy a file or directory.mv
: moves files and directories, can also be used to rename files (“move a file to a new name``).tab: auto complete commands, flags, files, folders, flags, … almost anything.
touch
: create an empty file, or update modification timestamp on a file.chmod
: change permissions for a file, such as read and write access.locate
: locate files/folders (may not be installed as default). Requires runningupdatedb
reqularly to update the search index.find
: find files/folders in the current working directory or subdirectories. Does not requireupdatedb
.clear
: clear terminal window (scroll it).
Less basic file and data manipulation:
echo
: print a string either to console or a file.cat
: concatenate files and print on the standard output.less
: show files/input in a scrollable way. Use q to quit.tar
: compress/extract files to/from.tar.gz
files. Similar tozip
/unzip
.zip
: compress files to a.zip
file.unzip
: extract files from.zip
files.wc
: count lines, words, bytes.grep
: print lines that match patterns.sed
: filter and transform text.diff
: compare files line by line (diff -u
produces a, perhaps, easier to read format).
Editors:
nano
: a very basic terminal-based text editor. Use Ctrl + x to quit.vim
: an advanced terminal-based text editor. Use :q Enter to quit.emacs
: an advanced terminal-based text editor.gedit
: a graphical text editor.
Informational commands:
df
: check the disk space usage on your system.du
: check the disk space usage for all files in the current directory.uname
: print system information (often called asuname -a
).hostname
: display the DNS name of your system.ping
: check if a IP address is live. Can also be used on URLs.
Administration:
sudo
: run commands with administrative or root privileges.apt
(orapt-get
): command for installing software on Ubuntu (also in WSL).
Program (job) control and information:
Ctrl + c: stop a program.
Ctrl + z: suspend a program.
fg
: continue a suspended program.jobs
: display status of programs (in this terminal).top
: display currently running programs on the computer with CPU and memory usage. Use q to quit.ps
: list currently running programs on the computer.