DEV Community

CarolinaCobo
CarolinaCobo

Posted on

36 Useful Terminal Commands

Here is a little list of terminal commands that you can find useful, I use some of them a lot and others from time to time.

  1. Print Current Working Directory. It will print the full path.
pwd
Enter fullscreen mode Exit fullscreen mode
  1. List of current directory contents
ls 
Enter fullscreen mode Exit fullscreen mode
  1. Change the directory
cd DirectoryName
Enter fullscreen mode Exit fullscreen mode
  1. To change to zsh shell.
chsh -s /bin/zsh
Enter fullscreen mode Exit fullscreen mode
  1. Clear the terminal logs
clear or cls
Enter fullscreen mode Exit fullscreen mode
  1. Copy files from the current directory to a different directory
cp source_file target_directory
Enter fullscreen mode Exit fullscreen mode
  1. Move files from the current directory to a different directory
mv 
Enter fullscreen mode Exit fullscreen mode
  1. Make a new directory
mkdir NameNewDirectory
Enter fullscreen mode Exit fullscreen mode
  1. Delete empty directories
rmdir 
Enter fullscreen mode Exit fullscreen mode
  1. Delete directories and contents within them (*be careful when using it)
rm DirectoryName
Enter fullscreen mode Exit fullscreen mode
  1. Create a new blank file
touch 
Enter fullscreen mode Exit fullscreen mode
  1. Find a file
locate
Enter fullscreen mode Exit fullscreen mode
  1. Search for files and directories within a given directory
find
Enter fullscreen mode Exit fullscreen mode
  1. Search through all the text in a file
grep FileName
Enter fullscreen mode Exit fullscreen mode
  1. Perform tasks that need admin or root permissions
sudo
Enter fullscreen mode Exit fullscreen mode
  1. Get a report on the systems disk space usage (% and KBs)
df 
Enter fullscreen mode Exit fullscreen mode
  1. Check how much space a file or a directory take
du 
Enter fullscreen mode Exit fullscreen mode
  1. View the first few lines of a text file
head
Enter fullscreen mode Exit fullscreen mode
  1. Display the last ten lines of a text file
tail
Enter fullscreen mode Exit fullscreen mode
  1. Compare the contents of two different files, line by line
diff 
Enter fullscreen mode Exit fullscreen mode
  1. Archive multiple files into a group of files collected together as one
tar
Enter fullscreen mode Exit fullscreen mode
  1. Change the read, write and execute permissions of files and directories
chmod
Enter fullscreen mode Exit fullscreen mode
  1. Transfer the ownership of a file to the specified username
chown
Enter fullscreen mode Exit fullscreen mode
  1. Display all current jobs along with their status
jobs
Enter fullscreen mode Exit fullscreen mode
  1. Terminate a program manually
kill
Enter fullscreen mode Exit fullscreen mode
  1. Check the connectivity status to a server
ping
Enter fullscreen mode Exit fullscreen mode
  1. Download files from the internet
wget 
Enter fullscreen mode Exit fullscreen mode
  1. Display a list of running processes and how much CPU each process uses
top
Enter fullscreen mode Exit fullscreen mode
  1. Get information about a Linux command
man
Enter fullscreen mode Exit fullscreen mode
  1. Move data into a file
echo
Enter fullscreen mode Exit fullscreen mode
  1. Compress files into a zip file
zip
Enter fullscreen mode Exit fullscreen mode
  1. Extract a zip file
unzip
Enter fullscreen mode Exit fullscreen mode
  1. Display the name of the host or network
hostname
Enter fullscreen mode Exit fullscreen mode
  1. Create a new user
useradd
Enter fullscreen mode Exit fullscreen mode
  1. Delete a user
userdel
Enter fullscreen mode Exit fullscreen mode
  1. After creating a user, it can be used to set a password for that user
passed
Enter fullscreen mode Exit fullscreen mode

Thanks for reading, I appreciate your time! 🎉 If you need any help please reach out!

If you have any questions feel free to drop me a message on LinkedIn or send me an email. 😊

Have a nice day!

Top comments (2)

Collapse
 
anderspersson profile image
Anders Persson

Kill have en very nice switch -9
kill -9 <process>
-9 tells kill to DO IT, sometimes a process will not stop and -9 force it.

Collapse
 
luciferrevenant profile image
Vandy Sodanheang • Edited

Oh, I think your ordering meant:

  1. ....
  2. ....

Something like this right?