Skip links

Handy Linux Commands

Below are a number of Handy Linux Commands arranged into various sections.

This article will be updated periodically.

Navigation and File Handling

List a directory

ls

 

Formatted List

ls -l

 

Formatted List show hidden files

ls-la

 

Change to the directory specified by <dirname>

cd dir

 

Change to parent directory

cd ..

 

Change to a directory specified by <dirname> in the parent

cd.. /dir

 

Change to home directory

cd

 

Change to root directory

cd /

 

Show current directory

pwd

 

Create a directory specified by<dirname>

mkdir <dirname>

 

Force Delete a file with name as specified by  <filename>

rm -f <filename>

 

Delete a directory with name as specified by <dirname>

rm -r <dirname>

 

Force Delete a directory with name as specified by <dirname>

rm -rf <dirname>

 

Copy a file called file1 to a file called file2

cp file1 file2

 

Move a file called file1 to a file called file2

mv file1 file2

 

Move a file called file1 to a file called file2 in a directory called <dirname>

mv file1 <dirname>/file2

 

Create or update file specified by  <filename>

touch <filename>

 

Output the contents of file specified by <filename>

cat <filename>

 

Write standard input to a file specified by  <filename>

cat > <filename>

 

Append standard input to a file specified by  <filename>

cat >> rm -r <filename>

 

Output contents of file specified by <filename> as it is updated

tail -f <filename>

Network

ping 8.8.8.8
whois <domainname>
dig <domainname>
dig -x <hostname>
wget <filename>
wget -c <filename>
wget -r <filename>
ip addr show
cat /etc/resolv.conf
curl <url>
curl -o output.html <url>
ssh user@hostname
ssh - port user@host
ssh -D user@host

System

date
uptime
whoami
w
cat /proc/cpuinfo
cat /proc/meminfo
free
du
du -sh
df
uname -a

Processes

ps
ps aux
kill pid
killall proc

Permissions

Modify permissions on file specified by <filename>

chmod xxx <filename>

 

Order for xxx as  owner/group/world

Numbers represent Read/Write/Execute=  4/2/1

 

Modify RWX for Everyone

chmod 777

Modify RW for Owner, RX for group world

chmod 755

Misc

Search in the file <filename> for the words <searchword(s)>

grep <searchword(s)> <filename>

 

Search recursvely in the directory for <searchwords>

grep -r <searchword(s)> <directoryname>

 

Find a file called <filename>

locate <filename>

 

Where is the app located specified by <appname>

whereis <appname>

 

Show help pages

man

This page was inspired by a jpeg that I saw on LinkedIn. Sadly there was no credit attributed.

 

Last Updated: 10 July 2022

Leave a Comment