File commands
Ls-Directory Listing
Ls-al-formatted listing with hidden files
CD Dir-Change directory to Dir
CD-change to home
PWD-show current directory
Mkdir Dir-create a directory dir
RM file-delete file
Rm-r Dir-delete directory dir
Rm-F file-force Remove File
Rm-RF Dir-force remove directory dir *
CP file1 file2-copy file1 to file2
CP-r dir1 dir2-copy dir1 to dir2; Create dir2 if it
Doesn' t exist
MV file1 file2-Rename or move file1 to file2
If file2 is an existing Directory, moves file1
Directory file2
Ln-s File Link-Create Symbolic Link link to file
Touch file-create or update File
Cat> file-places standard input into File
More file-output the contents of File
Head file-output the first 10 lines of File
Tail file-output the last 10 lines of File
Tail-F file-output the contents of file as it
Grows, starting with the last 10 lines
Process Management
PS-display your currently active processes
Top-display all running processes
Kill PID-kill process ID PID
Killall proc-kill all processes named proc *
BG-lists stopped or background jobs; resume
Stopped job in the background
FG-brings the most recent job to foreground
Fg n-brings job n to the foreground
File Permissions
Chmod octal file-change the permissions of File
To octal, which can be found separately for user,
Group, and world by adding:
● 4-read (r)
● 2-write (W)
● 1-Execute (X)
Examples:
Chmod 777-read, write, execute for all
Chmod 755-rwx for owner, Rx for group and world
For more options, see man CHMOD.
SSH
SSH user @ host-connect to host as user
Ssh-P port user @ host-connect to host on port
Port as user
Ssh-copy-ID user @ host-add your key to host
User to enable a keyed or passwordless Login
Searching
Grep pattern files-search for Pattern in files
Grep-r pattern Dir-search recursively
Pattern in Dir
Command | grep pattern-search for pattern in
Output of command
Locate file-find all instances of File
System Info
Date-show the current date and time
Cal-show this month's calendar
Uptime-show current uptime
W-display who is online
Whoami-who you are logged in
Finger user-display information about user
Uname-a-show kernel information
CAT/proc/cpuinfo-CPU Information
CAT/proc/meminfo-memory information
Man command-show the manual for command
DF-show disk usage
Du-show directory space usage
Free-show memory and swap usage
Whereis app-show possible locations of app
Which app-show which app will be run by default
Compression
Tar CF file.tar files-create a tar named
File.tar containing files
Tar xf file.tar-extract the files from file.tar
Tar CZF file.tar.gz files-create a tar
Gzip Compression
Tar xzf file.tar.gz-extract a tar using Gzip
Tar CJF file.tar.bz2-create a tar with Bzip2
Compression
Tar xjf file.tar.bz2-extract a tar using Bzip2
Gzip file-compresses file and renames it
File.gz
Gzip-D file.gz-decompresses file.gz back
File
Network
Ping host-ping host and output results
Whois domain-Get whois information for domain
Dig domain-Get DNS information for domain
Dig-x host-reverse lookup host
Wget file-download file
Wget-C file-continue a stopped download
Installation
Install from source:
./Configure
Make
Make install
Dpkg-I PKG. Deb-install a package (Debian)
Rpm-uvh PKG. rpm-install a package (RPM)
Shortcuts
CTRL + C-halts the current command
CTRL + Z-stops the current command, resume
FG in the foreground or BG in the background
CTRL + D-log out of current session, similar to exit
CTRL + w-erases one word in the current line
CTRL + U-erases the whole line
CTRL + R-type to bring up a recent command
!! -Repeats the last command
Exit-log out of current session
* Use with extreme caution.