Basic Linux Commands For Beginners

Ridwan Yusuf
4 min readMay 23, 2021

Basic Linux Commands You Should Know

There is a good chance that you’ll be working a lot of the time with the Terminal as a software developer. Linux is highly used in servers because they are super fast and secure. Windows is a good alternative but it costs in most cases.

In this tutorial, we will work you through some basic commands to use with Linux command-line interface(CLI). It is recommended to use CLI because it’s powerful and effective.

First off, fire up the Terminal by pressing Ctrl+Alt+T in Ubuntu. A Shell where you can start typing commands comes up immediately.

Basic Commands

1. pwd- Knowing the present location is very vital while working on a machine. By default, you are in the home directory when you first open the Terminal.

To know which directory you are in, you use the pwd

ray@ray-HP-EliteBook-8440p-SJ806UC:~$ pwd
/home/ray

2. ls - The ls command is used to view the files or contents that are present directory you are.

ls -a will show the hidden files while ls -a will show the files and directories with detailed information like size, etc.

3. cd - Use the cd command to navigate through files and directories.

For instance, if you are in the home directory and you want to go to the Documents directory, you simply type cd Documents

Note: cd is case-sensitive. This means cd will treat Documents and documents differently.

Use cd ..To move to the previous folder. You can also move to the previous directory using cd -

Tip: Say you need to move to a directory named my name. If you type cd my name,you get an error that says too many arguments. To achieve this, you should type cd my\ name instead.

4. mkdir - mkdir command is used to create a directory or a folder. For instance, if you type mkdir ExpressApp. A new folder called ExpressApp will be created with the command.

Tip: To create a directory called Express Project, Use either mkdir "Express Project" or mkdir Express\ App

5. rmdir - rmdir command is used to delete an empty directory. We use rm to delete a directory containing files. The folder to be deleted needs to be specified in front of the command.

rmdir MyNewFolder

6. rm - Use rm command to delete folders and files. To delete a folder and the files it contains, rm -r. Just like the rmdir command, you need to speficy the file or directory you want to delete.

rm choices.py

7. touch - The touch command allows you to create a new file. To create a simple text.txt file, you can use this command touch text.txt

8. cp - The cp command is used to copy files through the Linux shell. We need to specify two arguments in the cp command. The first is the file to be copied and the second is the destination. cp me.py /home/ray/Desktop This command copies me.py to the Desktop directory.

9. mv - The mv command is similar to the cp command. It is used to move a file to a new destination. To move me.py to the Documents directory,we can type this command:

mv me.py /home/ray/Documents

The mv command can also be used to rename files. It takes two arguments. The first being the new of the file to be renamed while the second arguments is the new name.

mv me.py new.py

10. man man command--Don't know about a specific Linux command? Linux got you covered with the man command. Type man followed by the command you want to know more about.

$ man cp

11. locate locate command - This command works like Windows search command. It comes in handy when you don't know where a file is located or you can't remember the exact name of a file you saved.

Using it’s -i argument makes the search case-insensitive.

locate -i news.py

This commad searches for news.py. To include more than one keyword, use * i.e.

locate -i product*socks

This Linux command searches for any file containing product and socks.

12. find - find command works similarly to locate command. The only difference is that you can only use find within a directory. It does not search beyond the current working directory.

13. cat - cat command is used to display the contents of a file in the Terminal. Type cat followed by the file's name and extension

cat news.py

Tips

clear: Use clear commad if the terminal is fillep up with too many commands

Ctrl+C: Use this to interrupt and stop any running in the Terminal

sudo halt and sudo reboot command shutdown and reboot the system respectively.

Tab is used for auto-completion in the terminal while typing.
cd Down and then Tab will auto-complete as cd Downloads.

--

--

Ridwan Yusuf

RidwanRay.com -I provide engineers with actionable tips and guides for immediate use