Getting Started Part 1: The most frequently used Linux commands!

You are currently viewing Getting Started Part 1: The most frequently used Linux commands!

Hello! In the Introduction, we discussed the advantages of SHAKTI and the changes it would bring in the processor ecosystem. Before understanding the complex workings of the processor, we are going to establish the basics with a series of articles. The first article in the series lists the most frequently used Linux commands.

Basic Linux Commands & Examples:

1. mkdir:

Make directory, Creates a new directory in the current location.

mkdir new_directory

2. cd:

Change directory, Changes to the specified directory.

$ mkdir new_directory
$ cd new_up  #moves inside the new_up.
$ mkdir new  #creates another directory.
$ cd new_low #moves inside "new_low".
$ cd ..      #moves back a level i.e moves back to new_up.
$ cd         #moves to home from any location.
$ cd new_up/new_low #goes to the specified path.

3. ls:

Lists all the files and directories in the specific locations. Its various parameters are as follows,

ls Lists all the non-hidden files
ls -aIt lists all the files in the specified direction including the hidden files
ls -lLists the contents of a directory in long format
ls -rIt lists the contents of a directory in reverse sort order.
ls -tLists the contents of a directory sorted by modification time.
ls /path/Lists the contents in the specified path


$ cd new_up
$ ls

4. pwd:

Displays the current location of the user.

$ cd new_up
$ pwd

5. man:

Displays a screen full of information about the specified command.

Use the Enter key to advance one line at a time, the 'b' key to go back, the Space bar to advance a full-screen page, and the 'q' key to exit the man page.

$ man ls

6. Creating a new text file:

Create a new text file or even a c file using any of the editors (gedit, vim, nano)

$ cd Documents
$ gedit a.txt
$ vim hello.c
$ gedit b.txt 
              #creates 3 files under Documents

7. cat:

Concatenation command,

  • Used for concatenating (merging 2 files)
  • Printing the contents of a file
$ cat /Documents/a.txt #displays the file
$ cat a.txt b.txt      #displays both the files, doesn't alter either
$ cat a.txt > b.txt  #a.txt in overwritten on b.txt, a.txt is the same
$ cat a.txt >> b.txt #a.txt is appended at the end of b.txt, a.txt is the same

8. rm:

Remove command, removes files and directories.

To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r.

$ rm a.txt #removes the file
$ rm -i a.txt #Gives a prompt before deletion.
$ rm -r new_directory #removes the folder and its contents

9. cp:

Copy command, copies files and directories.

cp a.txt /home/user Copies a.txt in Documents (Current folder) into home of user
cp a.txt b.txt newIt copies a.txt & b.txt into new folder in Documents
cp a.txt b.txt /home/userCopies a.txt, b.txt in Documents (Current folder) into home of the user
cp -r new /home/userIt copies “new” with its contents into home
cp -r -v new /home/userCopies “new” with its contents into home showing the progress
Assume you are currently in Documents which contains a.txt and b.txt and a folder new

10. ps:

Lists the current running processes.

This command is usually used with the parameter -a, -e. The most commonly used is “ps-aux“. “ps -aux” is used to list all the processes running in the system. It can be used with grep to obtain the required process. kill command can be used to kill the unwanted processes.

$ ps -aux | grep openocd #lists the openocd running in the system
$ kill PID #PID is the process ID

11. grep:

Searches a file for a particular pattern of characters, and displays all lines that contain that pattern.

grep [options] pattern [files]
Options Description
-i : Ignores, case for matching
-l : Displays list of filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-w : Match whole word

12. echo:

Displays the string that is passed as an arguement.

$ echo "Shakti"

13. touch:

Creates a file without content, changes and modifies the timestamps of a file.

$ touch a.txt b.txt c.txt d.txt    #Updates the timestamp of a.txt and b.txt & Creates two empty files (c.txt, d.txt)

14. mv:

Mostly used as rename command.

mv a.txt test.txt Renames a.txt into test.txt.
Assume you are currently in Documents which contains a.txt and b.txt and a folder new

Interested in learning more about SHAKTI? Click here!