In this article, we will go through some Linux commands that will help you use your Linux/Unix operating system through a terminal
Let's get started
First of all, open your terminal, most probably The keybinding to open a terminal session will be Alt+Ctrl+t
. What you will see is a clean terminal screen. Don't know where to go from here? Don't worry let us get your screen filled with text.
The
ls
command.ls
stands for 'List'. It lists all your directories and files in your current working directory.What is the current working directory?
The current working directory is the directory that is currently opened in your terminal session. If you just opened your terminal you will be in the
~
which is thehome
directory for your current user.To check your current working directory you can use the
pwd
command.pwd
stands for 'Print working directory'.Now that we see some directories on our screen. Let us change to those directories with the
cd <directory name>
command.cd
stands for 'change directory'. To change to a particular directory in this case let's change to theDownloads
directory we can writecd Downloads
(note: it is case sensitive).Now that we know how to move forward, let us learn how to move backward.
We can use
cd ..
to move a directory backward.Let us make a new directory now. Using the
mkdir <directory name>
command we can make a new directory.mkdir
stands for 'make directory'. For example, let us make a new directorytest
,mkdir test
. (cd into that directory)Now that we are inside our newly made directory, let us make some files, using the
touch <filename>
command.touch
is used to make new files. For example,touch newfile.txt
, this will create a new filenewfile.txt
.To edit the contents of a file. We have several terminal-based text editors, to keep it simple let us go with
nano
. To edit the text file using nano let us typenano newfile.txt
. Now you can write whatever you want and after that to save and exit, pressCtrl+x -> y -> Enter
.To print the contents of a file we use the
cat <filename>
command.cat
stands for 'concatenate',cat newfile.txt
will print all the contents of our file on our terminal screen.Now let us learn how to delete files, for that, we use the
rm <filename>
command.rm
stands for 'remove'.rm newfile.txt
will remove the text file that we just created.Remember we were inside the directory
test
that we just created. To delete that director we will have to go a directory backward.rmdir <directory name>
will delete our directory for us.rmdir
stands for 'remove directory'rmdir test
will delete the test directory.To exit our terminal we will use the
exit
command.
So these were some basic Linux commands that we learned today. Stay tuned for more such tutorials.