Navigating the Linux CLI

Navigating the Linux CLI

This article will explain basic Linux commands you would use for navigating the Linux CLI and some examples of how the commands are used.

Note: For Windows users, some terminologies might be new to you Examples are; Directory - this is equivalent to a folder.
Flag - flags are a way to set options and pass in arguments to the commands you run. Examples are -a, -r.

Some of these commands are listed below

  • mkdir ( make a new directory ) This command is used to create a directory or multiple directories.

image 1.png

with the -p flag it is used to create parent directories. eg mkdir -p test/alpha
This creates the parent directory test and the directory alpha under it.

image 2.png

  • pwd ( present working directory ) This command is used to show the directory you currently are in when the command was executed.

image 3.png

  • ls ( list contents) This command is used to show the content of the present directory you are on when the command was executed. When used with the -a flag ( shows all the contents including hidden files ) Note: if you run ls in an empty directory it will not output anything.

image 4.png

  • cd ( change directory ) This command is used to change from your present working directory to your specified directory. eg cd test

image 5.png

when you run the cd command without a specified destination it changes to the home directory.

image 6.png

  • touch ( create a new file ) This command is used to create a new file in the directory you specify. eg touch file.txt insert pictures below

image 7.png

  • cat ( concatenate ) This command is used to show the contents of a file without opening it, it is used to create one or more files and also redirect the output in the CLI.

image 8.png

  • rm ( remove/delete ) This command is used to delete specified files in a folder. when used with the -r flag, it can remove both the folder and its contents.

image 9.png

  • cp ( copy ) This command is used to copy files from one location to another. To use the command you need to provide the source ( where the file is located )and the destination ( where you want to copy the file to ) of the file or files you want to copy. insert pictures below

image 10.png

  • mv ( move ) This command is used to move files from one location to another. It follows the same principle as the cp command where you provide the source and destination during use.

image 11.png

The mv command can also be used to rename files. To do that you type mv the name of the file, then the name you want to change it into. insert pictures below

image 12.png

In conclusion, navigating the Linux CLI can be difficult especially for a beginner but the commands I have listed above should reduce the level of difficulty a beginner should have when trying to navigate the CLI.

Please like and share with a friend and you can also reach out to me via Linkedin or Twitter ... Until next time