Useful terminal commands for devs

Being practical is a one way ticket.

Bruno Muniz
4 min readJan 5, 2021

I always preferred using terminal over GUI apps to control my projects or to navigate through folders on my disk. I admit this is not really the most intuitive and friendly approach but one thing is for sure: once you get used to this you’ll want to use terminal for pretty much anything possible.

Photo by Markus Spiske on Unsplash


The touch command creates new, empty files. It is also used to change the timestamps (i.e., dates and times of the most recent access and modification) on existing files and directories.

touch empty_file.txt


The mkdir command allows the user to create directories (also referred to as folders in some operating systems ).

mkdir my_folder


The ls command is used to list files or directories. By using -a argument all the files including hidden ones get listed. When using -lh argument its possible to see also the permissions of the file and owners.

ls -a -lh


The pwd command prints the name of the current working directory.



The cp command stands for copy and — wait for it — is used to copy files or group of files or directory.

cp file.txt other_file.txt


The rm command stands for remove. It removes files but, in case we want to remove a folder and its content we need to use -r argument which means recursively. You can also use ‘*’ when referring to everything in the current working directory.

rm any_file.txt

rm -r photos


The cd command stands for change directory. It is used to change the current working directory and can be used by passing either the path forward or ‘..’ to navigate back or even simply ‘cd’ to navigate to root.

cd path/to/something


The clear command cleans the current displayed output on the terminal.



The sudo command allows you to run programs with the security privileges of another user (by default, as the superuser).

sudo open some_file.txt


The chown command is used to change the owner of file system objects (files and directories). The name is an abbreviation of change owner.

chown root file.txt


The chmod command is used to change the access permissions of file system objects (files and directories). The name is an abbreviation of change mode. The permissions can look something like this: -rwx rwx rwx. r=read, w=write, x=execute. If there’s a dash it means there’s no permission. The first three on the left refers to permissions for the current user. The three in the middle refers to the user group and the last three to others.

chmod 600 file.txt

600 will result on a permission of read and write for the current user, no permission for execution for this same user and nothing to anyone else. 6 is 110 in binary, which means (1)true (1)true (0)false = rw-

Let’s say we wanted full permission for everyone — we would use the number 777 because in binary that’s 111 111 111 = rwx rwx rwx


The cat (short for “concatenate“) command allows us to concatenate files and redirect output in terminal or files.

cat name_list.txt


The grep command is one of my favourites. Its used to search for a string on a file. It goes very well along with the next commands.

grep Bruno


The pipe command (which is simply ‘|’) helps you mix two or more commands at the same time and run them consecutively.

cat name_list.txt | grep Bruno


The tail command prints the last few number of lines (10 lines by default) of a certain file, then terminates. When using -n argument its possible to define the exact amount of lines to be printed. The -f argument causes tail to not stop when the end of the file is reached, but rather waits for additional data to be appended to the input.

tail -n 5 -f


The man command is used to display the user manual of any command that we can run on the terminal. It shows all the arguments that can be passed to a command.

man tail

man grep

Special thanks to Richard Carback and Ben Wenger for introducing me to some of those commands.