Linux provides a diverse range of commands, bellow is a list of the most relevant commands.
alias
Gives a specific name to a command or sequence of commands.
alias cls=clear
alias pf="ps -e | grep PATH
exit
Exit an ssl session.
find
Finds file location.
find . -name *ones*
find . -type f -name *ones*
find . -iname *wild*
. matches the current folder. -name *ones* the file name contains the string ‘ones’, -iname not a case sensitive search.
finger
Get user information.
free
Current memory usage.
free -h
grep
Searches lines that contains a specific string.
grep train *.txt
groups
Get a user’s group.
groups ayoub
gzip
Files compression.
gzip -k core.c
-k for keep.
head
Returns the first 10 lines of a file.
head -n 5 core.c
-n for more lines.
history
Shows the history of the used commands.
history
!19
!!
!19 use the command 19 displayed in the history. !! use the last command.
kill
Terminate a process.
ps -e | grep shutter
kill 1692
less
View files without opening an editor.
less core.c
ls
Lists the files and folders in a specific directory.
ls -lha
-l for long files, h human friendly, a hidden files.
man
Displays user manual pages in less mode.
man chown
mkdir
Creates a new directory.
mkdir -p quotes/yearly/2019
-p for parents (creates parents too).
mv
Moves files and directories.
mv ~/Documents/manuals/Apache.pdf ./The_Shadows_Apache.pdf
passwd
Change user password.
sudo passwd ayoub
ping
Verifies current network connectivity with another network.
ping -c 3 -a 8.8.8.8
-c for attempts, -a to hear a ping.
ps
Lists current running processes
ps -u dave | less
ps -e | less
-u for a particular user, -e for every process.
pwd
Current working directory.
shutdown
shutdown +15 Shutting down in 15 minutes!
shutdown -c
-c to cancel shutdown.
SSH
Allows to establish a connection to a remote Linux computer.
ssh ayoub@192.168.4.23
sudo
For actions that require root access.
sudo passwd ayoub
tail
List the first 10 (default) or n lines of a file.
tail -n 5 core.c
tar
Creates a tarball archive file.
tar -cvzf songs.tar.gz ayoub/
-c for create, -v for verbose, -f for file, z (gzip) for compression. j (bzip2) for superior compression algorithm.
top
Displays the current machine realtime data and information.
uname
Displays current system information. -a for all, -s -r -v for kernel name, release, and version.
whoami
Determines whether you’re logged or not.
w
Displays current logged users.