Most Common Linux Commands That You Must Know

Mohasin Hossain
3 min readMar 17, 2022

In this tutorial, I am going to share most commonly used Linux commands that most of developers use in daily programming life. Let’s start walking…

Make sure you open your terminal to practice the commands.

ls command: to show the content of a directory

ls    : current directory folders
ls -a : current directory folders all with hidden
ls -l :current directory folders with extra more info

pwd command: to show the current directory path e.g. /home/yourname/current-directory

pwd

cd command: change directory

cd : go to home folder
cd / : go to root directory
cd fodler-name : go to fodler-name directory
cd folder1/nextfolder/myfolder : go to myfolder directory
cd .. : move a level up or one step back
cd - : return the previous directory

cp command: to copy file or folder

cp copy_me.txt new_file.txt
cd -r folder1 folder2

rm command: to remove file or folder

rm delete_me.txt
rm -r folder1 : use -r to remove an empty directory
rm -rf folder1 : use -rf to remove directory with content
rm -r : to remove current directory all content

mv command: move folder

mv your_file where_to_move
mv new_file.txt folder1
mv /home/yourname/folder_to_move ./ (note: ./ is your current directory)
mv old_file.txt new_file.txt : mv is also used to rename file name

mkdir command: to create directory

mkdir folder1
mkdir -p folder1/folder2/ : to create subdirectory user -p

man command: to show all of the options & description of any command

man mkdir : it will show every option & details of mkdir command

touch command: to create a file

touch new_file.txt

nano command: to open and modify a file

nano new_file.txt

cat command: to display the content of a file

cat new_file.txt

clear command: to clear the terminal

clear

history command: to show all used command list

history

chmod command: to change the mode of a file (permission). There are some options for chmod command like r(read), w(write), x(execute)

chmod +r folder1 : to give read permission for directory folder1

exit command: end a shell session

exit

sudo command: superuser do

sudo apt install apachi2

shutdown : power of your pc

shutdown now 
Sudo shutdown -h 10 : will shutdown after 10 minutes
shutdown 12:30

htop command: interactive process viewer like task manager of windows

htop

zip command: to zip any file

zip -r zip_folder_name zip_me

unzip command: to unzip a zip file

unzip images.zip

apt command: apt is package manager of linux/ubuntu

sudo apt install mysql

kill command: to close any program

kill firefox

ping command: to see the ip address of any website

ping google.com

vim command: vim is a text editor like nano command

vim
vim file.txt

passwd command: to set or change user password

passwd

which command: gives the path of any directory

which directory-name

wget command: to download any content from internet

wget https://github.com/mohasinhossain/SOLID-Principles-in-PHP

That’s all for now. Please feel free to leave a comment if you have any feedback, questions or want me to write about another PHP/Laravel related topic.

--

--

Mohasin Hossain

Senior Software Engineer | Mentor @ADPList | Backend focused | PHP, JavaScript, Laravel, Vue.js, Nuxt.js, MySQL, TDD, CI/CD, Docker, Linux