Basic Linux commands you should know
|
ls – directory listing
|
|
ls -al – formatted listing with hidden files
|
|
cd [directory] - change directory to directory
|
|
pwd – Print Working Directory
|
|
mkdir [directory] – create a directory named directory
|
|
rm [file_name] – delete filename
|
|
rm -r [directory] – delete directory recursively
|
|
rm -f [file_name] – force remove file
|
|
rm -rf [directory] – force remove directory directory recursively * Use with care
|
|
cp [file1 file2] – copy file1 to file2
|
|
mv [file1 file2] – rename or move file1 to file2
|
|
ln -s [file_name link] – create symbolic link to file
|
|
touch [file_name] – create or update file
|
|
cat > [file_name] – places standard input into file
|
|
more [file_name] – output the contents of file
|
|
head [file_name] – output the first 10 lines of file
|
|
tail [file_name] – output the last 10 lines of file
|
|
tail -f [file_name] – output the contents of file as it grows, starting with the last 10 lines
|
|
chmod [octal file_name] change the permissions of file to octal
|
|
tar cf [file_name.tar files] – create a tar named file_name.tar containing files
|
|
tar xf [file_name.tar] – extract the files from file_name.tar
|
|
tar czf [file_name.tar.gz files] – create a tar file with Gzip compression
|
|
tar xzf [file_name.tar.gz] – extract a tar using Gzip
|
|
tar xjf [file_name.tar.bz2] – extract a tar using Bzip2
|
|
gzip [file_name] – compresses file and renames it to file_name.gz
|
|
gzip -d [file_name.gz] – decompresses file_name.gz back to file
|
|
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 as
|
|
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 [application_name] – show possible locations of binary, source, and manual page files for a command
|
|
which [application_name] – show which application will be run by default
|
|
grep [pattern files] – search for pattern in files
|
|
grep -r [pattern directory] – search recursively for pattern in directory
|
|
[command] | grep [pattern] – search for pattern in the output of command
|
|
locate [file_name] – find all instances of file
|
|
ps – (Process Status) displays your currently active processes
|
|
top – (Table of Processes) display all running processes
|
|
kill [pid] – kill process id pid
|
|
killall [process_name] – kill all processes named [process_name]
|
|
bg – lists stopped or background jobs; resume background job
|
|
fg – brings the most recent job to foreground
|
|
fg [n] – brings job id to the foreground
|
|
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 at URL] – download file from URL
|
|
wget -c [file at URL] – continue a stopped download
|
|
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 for user to enable a keyed or login without password
|
|
Ctrl+C – halts the current command
|
|
Ctrl+Z – stops the current command; resume with 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
|
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.