Photo of option and command keys on apple keyboard — by Angie Delgado
Commands and their options

15 Commands to Help You Navigate the Bash Shell

Angie DelGado
3 min readApr 30, 2020

--

If you want to get good at writing commands in your terminal, these are the top fifteen you definitely need to know! Some of these commands can be used with options, others do not have options. There are more than just these fifteen commands that can be used on the Bash shell or (Bourne Again Shell) which according to William E. Shotts from the Linux website, “it is a program that takes commands from the keyboard and gives them to the operating system to perform.” For now, we will focus on these: man, cd, ls, >, mkdir, touch, mv, cp, pwd, rm, rmdir, echo, cat, clear, and exit.

man [COMMAND] — this command will show you the manual for any command you search for. This is probably the most important command, without it, you would be searching online for a long time to find all the flags that one single command can use.

cd [OPTIONS] [args …] — this command addresses the current directory. When used like this “cd ..” it will go back one directory to the parent directory. If only “cd” is used you will move to the home folder.

ls [OPTIONS] — The ls command lists all the files within the folder/directory you’re in. This command has several flags that can be used. Some of these flags like -a can be used to show all files including the hidden files that are in a folder.

> — This is the redirect operator. It will take the output from a previous command and add it to a file. It is often used with the “echo” command “hello” > newFile. Here it will create a file called newFile and it will add the echoed string into it.

mkdir [OPTIONS] [args…] — makes a new directory with a name.

touch [filename] — makes a new file.

mv [OPTIONS] source, target — the mv file can be used to move files from one folder to another, and it can also be used to rename files.

cp [OPTIONS] source, destination — the “cp” command can be used to copy the contents of one file into another, as well as directories and folders. It will make an exact copy of whatever is copied.

pwd [OPTIONS]— print working directory, this command helps you see what directory you are in.

rm [OPTIONS] file — removes files.

rmdir [OPTIONS] directory— removes directory entries and when used with the correct flags it will recursively delete anything inside those folders.

echo [OPTIONS] [string …] — the echo utility writes into a file.

cat [OPTIONS] filename — has several uses, but the most important one is the use to display the contents of a file.

clear — clears the terminal screen.

exit [OPTIONS] — exit the terminal.

Hopefully, these commands help you feel more confident when navigating the shell. Keep practicing and learning more and soon you will be a master on shell commands. ¡Pura Vida!

You once you master all the commands.

--

--

No responses yet