Basic linux commands
This is a list of all basic linux commands you should know.
Of course this is my personal opinion.
What do you think?
Files and navigation
ls - directory listing of current directory
ls -l - formatted listing
ls -la - formatted listing including hidden files
cd dir - change directory to dir (dir = name of directory)
cd .. - change to parent directory
cd - change to home directory
cd - - change to previous visited directory
cd ../dir - change to dir in parent directory
pwd - show current directory
mkdir dir - create a direcotry "dir"
rm filename - delete file
rm -f filename - force remove filename
rm -r dir - delete directory
rm -rf dir - force delete of directory
cp file1 file2 - copy file1 to file2
mv file1 file2 - rename file1 to file2
mv file1 dir/file2 - move file1 to dir as file2
touch filename - create or update file
cat file - output contents of file
cat > file - write standard input into file
cat >> file - append standard input into file
tail -f file - outputs contents of file as it grows
Networking
ping host - ping the host
whois domain - get whois for domain
dig domain - get DNS for domain
dig -x host - reverse lookup host
wget file - download file
wget -c file - continue stopped download
wget -r url - recusivley download files from url
curl url - outputs the webpage from url
curl -o output.html url - writes the page to output.html
ssh user@host - connect to host as user
ssh -p port user@host - connect using port
ssh -D user@host - connect & user bind port
Processes
ps - display currently active processes
ps aux - detailed outputskill pid - kill process with process id (pid)
killall proc - kill all processes named proc
System info
date - show current date/time
uptime - show uptime
whoami - who you are logged in as
w - display who is online
cat /proc/cpuinfo - display cpu info
cat /proc/meminfo - memory info
free - show memory and swap usage
du - show directory space usage
du -sh - displays readable sizes in GB
df - show disk usage
uname -a - show kernel config
Compressing
tar cf file.tar files - tar files into file.tar
tar xf file.tar - untar into current directory
tar tf file.tar - show contents of archiveoptions:
- c - create archive
- t - table of contents
- x - extract
- z - use zip/gzip
- f - specify filename
- j - bzip2 compression
- w - ask for confirmation
- k - do not overwrite
- T - files from file
- v - verbose
Permissions
chmod octal file - change permissions of file
- 4 - read (r)
- 2 - write (w)
- 1 - execute (x)
order: owner/group/world
chmod 777 - rwx for everyone
chmod 755 - rw for owner, rx for group and world
Some others
grep pattern files - search in files for pattern
grep -r pattern dir - search for pattern recursively in directorylocate file - find all instances of file
whereis app - show possible locations of app
man command - show manual page for command
Top comments (1)
😍 Amazingly comprehensive list of commands!! Definitely using this in the future.