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:
Make directory, Creates a new directory in the current location.
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.
Lists all the files and directories in the specific locations. Its various parameters are as follows,
|Lists all the non-hidden files|
|It lists all the files in the specified direction including the hidden files|
|Lists the contents of a directory in long format|
|It lists the contents of a directory in reverse sort order.|
|Lists the contents of a directory sorted by modification time.|
|Lists the contents in the specified path|
$ cd new_up $ ls new_low
Displays the current location of the user.
$ cd new_up $ pwd /home/username/new_up
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
- 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
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
Copy command, copies files and directories.
SYNTAX : cp [OPTION] SOURCE DESTINATION
|Copies a.txt in Documents (Current folder) into home of user|
|It copies a.txt & b.txt into new folder in Documents|
|Copies a.txt, b.txt in Documents (Current folder) into home of the user|
|It copies “new” with its contents into home|
|Copies “new” with its contents into home showing the progress|
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
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
Displays the string that is passed as an arguement.
$ echo "Shakti" Shakti
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)
Mostly used as rename command.
|Renames a.txt into test.txt.|
Interested in learning more about SHAKTI? Click here!
Akshaya currently works at the RISE labs. Her favorite subjects are Web designing and Microprocessors. She loves learning about new things and writing about them!