Due to the nature of Linux-based operating systems, many operations are performed through the terminal. In this process, we wanted to share with you the basic commands that will make your work easier.
Here are the top Linux commands we have prepared for you:
Command | Description | Usage |
---|---|---|
cd | The cd command is used to navigate through folders. | $ cd path_the_folder $ cd .. (Go to the parent folder) |
ls | The ls command is used to list files in a folder. | $ list (list only file_names) $ ls -la (detailed file information) |
mkdir | The mkdir command is used to create a folder. | $ mkdir folderName |
rmdir | The rmdir command is used to remove a folder. | $ rmdir folderName |
touch | The touch command is used to create an empty file. | $ touch fileName.txt |
cp | The cp command is used to copy a file or folder. | $ cp [source_file_or_folder] [target_file_or_folder] |
mv | The mv command is used to move or rename a file. | $ mv [source_file] [target_file_with_new_name] |
rm | The rm command is used to remove a file. | $ rm fileName |
cat | The cat command is used to print the contents of a file to the terminal. | $ cat fileName |
head | The head command is used to print the contents of a file with the number of lines from beginning to end to the terminal. | $ head (10 lines) $ head -n number_of_lines |
tail | The tail command is used to output the contents of a file from the back to the top with the number of lines. | $ tail (10 lines) $ tail -n number_of_lines |
less | The less command is used to display the output of a command and a file page by page. | $ less fileName or command |
whoami | The whoami command is used to display who the active user is. | $ whoami |
id | The id command is used to display the information of the user or group. | $ id |
uname | The uname command is used to display the kernel and processor information of the system used. | $ uname -a (for all information) |
su | The su command is used to switch to the root user or another user. It is short for “super user”, “switch user” or “substitute user”. The password of the user to be switched must be entered. | $ su username |
sudo | The sudo command is used to run a command with root privileges. When the command ends, it returns to normal user privileges. | $ sudo [command] |
passwd | The passwd command is usually used to change the user password, but can also be used to lock the user and override her password. | $ passwd (loged user) $ passwd username (another user) |
useradd | The useradd command is used to create a new user. | $ useradd username |
userdel | The userdel command is used to delete a user. | $ userdel username |
hostname | The hostname command is used to display hostname. | $ hostname |
grep | The grep command is used to search for a word in files and to output the files that have that word. | $ grep -rl “search_word” |
find | The find command is used to search filenames and list matching files. | $ find / -name “fileName” |
which | The which command is used to search the directories specified by the $PATH variable in the environment variables of a command and find the executable file. | $ which [command] |
locate | The locate command is used to search by filename in “locate” like “find”. | $ locate word |
history | The history command is used to output the previously written commands. | $ history |
pwd | The pwd command is used to output the current file path. | $ pwd |
who | The who command is used to display the users who are currently online in the system. | $ who |
chmod | The chmod command is used to change the authorization required for users to access and run files. It is short for “change mode”. | $ chmod +x fileName (To give run permission to all users) |
apt | The apt command is used to install, uninstall and update the system and applications. It is short for “Advanced Package Tool”. RedHat-based systems use yum. | $ sudo apt install appName (to install the app) $ sudo apt remove appName (to remove the app) $ sudo apt upgrade appName (to upgrade the app) $ sudo apt update (update the package database) $ sudo apt upgrade (upgrade the system and apps) |
man | The man command is used to call up detailed documentation about a command. | $ man [command] |
chown | The chown command is used to change the ownership of a file or folder. | $ chown [username] [fileName or folderName] |
top | The top command is used to get detailed information about the processes running in the system. | $ top |
ps | The ps command is used to list running processes. | $ ps -aux |
wget | The wget command is used to download files over http, https and ftp protocols. | $ wget [url] |
tree | The tree command is used to see the skeleton structure of other files and folders in a folder. | $ tree folderName |
df | The df command is used to see the disk space usage information of the file system. | $ df /home/user |
wc | The wc command is used to output the number of lines, the number of words, and the number of characters in a file. | $ wc fileName |
clear | The clear command is used to clear the command line. | $ clear |
reboot | The use of reboot is not recommended, instead “shutdown -r” provides a safer reboot. (for old systems) | $ reboot or shutdown -r |
shutdown | The shutdown command is used to shut down the system. When the “shutdown” command is used alone, it shuts down the system after 1 minute. If you want to shut down the system immediately, you can use the “shutdown now” command. | $ shutdown now |
tar | The tar command is one of the most used commands for file and folder compression. | $ tar -cvf Archive.tar /home/Archive $ tar -cvzf Archive.tar.gz /home/Archive (for better compression than tar) |
kill | The kill command is used to kill a process. For different alternatives: How to kill a process in Linux | $ kill [processID] or kill -9 [processID] |
ping | The ping command is used to verify whether another device on the IP network is reachable. It is short for “Packet Internet Groper”. | $ ping [IP] |
zip | The zip command is used for file and folder compression. | $ zip -r archive.zip fileName $ zip -r archive.zip folderName/ |
unzip | The unzip command is used to uncompress the compressed files. | $ unzip archive.zip |
mount | The mount command is used with the address and mount point of the new device to be mounted in an existing directory. | $ mount -t type device directory |
traceroute | The traceroute command is used to detect the path traveled until reaching a server. | $ traceroute [domain or IP] |
date | The date command is used for setting the date and the time. When you type the command alone, it outputs the current date and time. | $ date $ date -s “2 NOV 2021 17:45:12” (for change the system time) |
open | The open command is used to open files and folders with the user interface. | $ open fileName $ open folderName |
Top 50 Linux Commands PDF download
Click here to download the Top 50 Linux Commands as pdf file.