Command |
Action |
options: command -abc or command -a -b -c |
man command |
Enter the Manual Page application at command. Example: man ls |
f - whatis, k - apropos, man command | less - pages command output |
whereis file |
find path(s) to a file or application |
|
apropos keywords |
find man pages with keywords |
|
whatis command |
show man page summary for command |
w - supports wild cards, e.g., whatis -w ls* |
which |
if more than one instance of executable tells which will run and shows where it is |
b - show only binaries, a - show all locations |
clear |
clear terminal screen |
|
ls [pattern w/ wildcards] |
display directory listing |
l - long, R - recursive, r - reverse, a - show hidden, F - classify, X - sort by extension, t - sort by date/time, S - sort by size |
pwd |
path of current(working) directory |
|
cd path |
change to path |
may be absolute or relative |
mkdir name |
create name directory |
p - create nested dirs, e.g., name1/name2/name3 |
cp src dest |
copy file(s) or directory from src to dest |
i - interactive when overwriting, R - copy directory recursively, a - don't follow soft links |
mv src dest |
move and rename files |
|
rm |
delete files |
i - interactive, Rf - remove files and directories |
rmdir |
delete empty directories |
|
su account |
impersonate another account if you have password |
|
sudo |
elevate priviledges to root for single operation with your credentials |
|
whoami |
current account |
|
cat file1 file2 |
concatenates and displays contents of all files in set, e.g., cat -n *.h main.cpp |
n - numbers lines |
less file |
displays one page of text, then supports navigation with up/down and PageUp/PageDown keys.
Search by entering /regexpression.
|
N - number lines |
head file1 file2 |
display top few lines |
n 5 - number of lines to display, default is 10 |
tail file1 file2 |
display last few lines |
n 5 - number of lines to display, default is 10 |
tail -f logfile |
continuously displays the last 10 lines of changing file Ctrl+c terminates display |
|
lpr file |
sends file text to default printer |
P printerName - sends to non-default printer |
chown account file |
change owner of file |
|
chmod [ugo][+-=][rwx] |
change permisions for user, group, others |
R change recursively |
zip name.zip src |
src can be a list of files or directories |
[1-9] - degree of compression. 1 is none, 9 is max |
unzip name.zip |
unzips in place |
l - list contents without unzipping |
grep regExp file(s) |
displays lines that match regExp, e.g., grep "^#" main.cpp finds preproc statements |
R searches recursively for files to search grep -R thread *.h *.cpp C 3 - shows context v - inverts pattern
|
locate filename |
finds file by looking up in database so it's fast. |
i - case insensitive search |
updatedb |
reindex file system to include new files |
|
find -name patter |
recursively searches for files matching pattern, displaying path |
Searches filesystem, not database so it's slower. |
history |
show commandline history |
|
alias |
display list of all aliases defined in .bashrc or .bash_aliases |
|
ps aux |
show running processes |
|
top |
show summary stats then a dynamic list of processes with high %cpu and %mem |
|
kill pid |
kill process |
|
apt-get install package |
install package and all its dependencies |
|
apt-get update |
update available package list |
|
apt-get upgrade |
install more recent versions of installed packages |
|
apt-get remove package |
removes package and its dependencies if not needed for other packages |
|
apt-cache search package |
searches repositories for package versions and related packages |
apt-cache search gcc | less |
Note: case is important |