Commands
From Computer Science
Revision as of 19:21, 9 February 2020 by Robert Lichenstein (talk | contribs)
Introduction
This page enumerates, categorizes, and very briefly describes a bunch of Linux
command-line programs that you may find useful. The documentation provided
here is (intentionally) insufficient to actually use them; recall that you can
use the man
command to read the online manual page (arrow keys and pgup/pgdn
scroll, 'q' to exit). Therefore, to read about all the options accepted by
the ls
program, run
$ man ls
Some of the programs below are standard, as part of the "coreutils" and "util-linux" packages in Arch Linux; others will need to be installed separately.
Vocabulary
Only one right now.
- Recursive refers to an operation that descends into child directories,
- their children, their children's children, and so forth. Therefore,
- applying the '-r' parameter to
grep
will cause it to search not only the - files in the current directory, but also all files within and below it.
Commands
The single most important one
man
: access the online manual
The second most important one, for system administration
sudo
: run a program with temporarily-increased privileges
Get me outta here
exit
: terminate the terminal sessionlogout
: terminate the terminal sessionCtrl-d
: terminate the terminal session (only when no other characters have
- been entered at the prompt; otherwise behaves as Enter)
Basic filesystem stuff
pwd
: report the current working directoryls
: list information about filescd
: change to a different directorymkdir
: create a directorymv
: move a file (equivalent to renaming it, even if its new name puts it
- in a new directory)
cp
: copy a filerm
: remove a filermdir
: remove a directorytouch
: create a file or, if the file exists, update its modification
- time
chmod
: change permissions of a filechown
: change ownership (user/group) of a fileln
: create a (symbolic) link
Text analysis
grep
: search inside file(s)wc
: count characters/words/lines in a fileecho
: output a string to the terminalcat
: output the contents of a file to the terminalhead
: print lines from the beginning of a filetail
: print lines from the end of a filediff
: compare the contents of filesless
: allow keyboard-based scrolling through a file (manpages are run
- through less, thus the same navigation commands apply)
Text manipulation
sort
: you'll never guessuniq
: filter out consecutive duplicate lines from a filecut
: combine files line by linepaste
: separate files line by linesed
: modify files, line by line, according to regular expressionsawk
: lightweight programming language for modifying files line by linefold
: break long lines into paragraphsfmt
: more complex version of foldcolumn
: neatly format text into evenly-spaced columns
More complex file stuff
find
: locate files based on metadata (eg, name, size, modification time)xargs
: often used to send the results of find to other programstar
: create an archive containing multiple filesgzip
: compress a file (historically ubiquitous)xz
: compress a file (more recently popular)stat
: report metadata information about a filedd
: copy file contents (more tweakable than cp, useful for copying from
- raw devices, eg, /dev/urandom)
Measuring and monitoring
du
: measure sizes of files/directoriestime
: measure the runtime of a programps
: list running processes (instant snapshot)top
: list running processes (updates repeatedly)
Random
date
: report the datesleep
: pause for a configurable durationhistory
: list recently-run commandsclear
: clear the terminal screenreset
: clear the terminal screen with extreme prejudice (useful if you want to
- erase the scrollback buffer or reverse text corruption when playing with, eg, customized fonts/colors in your shell)
Network
ifconfig
: report information about network interface configuration
- (classic tool)
ip
: report information about network interface configuration (newer tool)route
: manipulate routing tablenetstat
: report information about network configurationping
: check reachability of machines over the Internettraceroute
: trace the route to another machine on the Internetmtr
: trace the route to another machine on the Internet (my preferred choice)netcat
: the Swiss Army Knife of the Internetwget
: save web pages as filescurl
: save web pages as files (alternate)
More complex
ssh
: log into a machine over the Internetrsync
: efficiently copies files (even across the Internet)tmux
: resumable terminal sessionsscript
: record the results of a terminal session in a filecron
: schedule programs to be run at certain timesbc
: do math