50 Most Useful Linux Commands for VLSI Engineers

 

Linux is an open-source operating system which is the first choice of every technocrat. For VLSI Design Engineers also most of the EDA tools are only compatible with Linux. In Linux, we interact with OS majorly with Command-Line Interface (CLI). In beginning, it might look a bit tedious as you have to remember lots of commands and we are addicted to GUI interface but later you will definitely love it.

In this article, we will learn some of basic Linux commands with examples. I would request to my reader don’t just read this article but, practice these commands parallelly for best understanding and clarity. If you wish you can also make a small cheat sheet for your use. In this article, we will learn 4 categories of 50 most useful basic commands. For advance level commands we are going to publish another article later.

 

 

Category-1:  File System Management

 

1.  ls

: list files and directories

 
Use:

    ls -l   ; indicates file/directory type, permissions, owner, size, last modified

        – normal, d- directory, s-socket file, l-link file

    ls  -a  ; shows hidden files/directories

    ls -t   ; lists the files/directory on basis of modification time

    ls -lart   ; lists all the files and directories in order of last modified.

 

2.  clear 

: clear the terminal (but keep the history of commands intact)

 

3.  man / –help 

: Show a manual of command and switches written in details.

 

4.  pwd

: Print Working Directory, The directory where you are currently.

 

5.  cd

: Change Directory, to move to another directory.

 

 

Use:

    cd  .. ; back to parent directory 

    cd  – ; back to previous directory 

    cd ~ ; go to home directory

    cd ../../../ ; back to n steps

    cd ‘abc xyz’   ; go to a directory whose name contain white space

 

6.  mkdir

: create a directory

 

Use:

    mkdir directory_name ; To create a new directory with the given name.

    mkdir dir1 dir2 dir3 ; To create multiple directories in a single step.


 

7.  touch

: create a file

 

Use:

    touch file_name ; create a new file

    touch file1 file2 file3 ; To create multiple files

    touch –a file_name ; to change file access time

    touch –m file_name ; to change the file modification time  

 

8.  gedit file_name &

: create and edit a file in GUI mode

 

Use:

    gedit /path/to/file_name ; create and edit a file in specified location

                                                  ; word count, line no. , language 

9.  vi file_name

: create and edit a file using command-line interface

 

Use:

    i    ; Switch to edit mode

    ESc    ; Exit from edit mode and Switch to command mode

    /string ; find the string

    Esc + :q ;exit without saving

    Esc + :s   ; Save only not exit

    Esc + :wq  ; save and exit

 

10.  cp source destination

: copy command

 

Use:

    cp source_file destination_dir     ; To copy a file

    cp source_file .     ; To copy a file to current directory (“.” means current dir)

    cp -f source_file destination_dir     ; To copy forcefully a regular file

    cp -R source_file destination_dir ; To coppy recursive a directory

 

11.  mv source destination

: move command, like cut+paste

 

Use:

    mv f1 f2     ; rename f1 by f2

    mv -rf   ; recursive and force moving of a directory

 

12.  rm

: remove file/directory, like delete

 

Use:

    rm -rf   ; remove recursive and force

                    ! One of the dangerous commands for root, use carefully!!!

    rm *.txt ; Will remove all the file having extension .txt in PWD

13.  cat 

: stands for concatenate

 

Use:

    cat file_name   ; Display a contain of a file in CLI

    cat text1 > text2 ; redirection of text, overwrite

    cat text1 >> text2 ; appending the text 

 

14.  which 

: Path of the command

 

Use:

    which virtuoso ; Display the path of the executable file for virtuoso

    which vi ; Will show the vi command path

    which python ; Will show the installation path of the python program

15.  find 

: searching a file/directory

 

Use:

    find / -name “dir_name” ; to find a file/dir

    find /home/user_name -name “file_name” ; to find a file/dir only in user’s home area

    man find ; to get more details on find command

 

 

 

16.  history 

: Get the list of executed commands

 

Use:

    history ; the history of all command

    history n   ;list of last n command executed

                !n            ; repeat any command in the history list

    export HISTTIMEFORMAT=‘%F %T ’   ; setting history command with timestamp format

    unset export HISTTIMEFORMAT ; unsetting the time format

    history -c ; clear all the history

    ~/.bash_history ; location of stored command history

 

17.  chmod

: Change mode, change the permission of file/directory

 

Use:

    ls -l  file_name          ; To see the current permissions of the file/dir

 

Let’s understand the permissions through this ecample.

 

 

r   w   x 7     7     7 7      5      4

4   2  1 rwx  rwx rwx rwx   r-x    r- –  

 

Numeric and Symbolic permissions

    chmod  777 file_name         ; set all the permission for all users

    chmod  754 file_name        ; set rwx for owner, r-x for the group and r– for others

    chmod –R 777 dir_name    ; Set all permission recursively inside the dir

 

 

 

Category-2:  Text processing commands

 
 

18. touch

: create a new file

 

Use:

    touch file1 ; create an empty file

    touch file1 file2 file3 ; create multiple files in one command

    touch –am file2   ; change access and modification time

 

19. gedit

: A GUI based Linux text editor  

 

Use:

    gedit & ; open gedit text editor and release the CLI

    gedit file1 ; create/open a file in geditor

 

20. head

: To read the first 10 lines of a file in CLI  

 

Use:

    head file_name   ; To read the first 10 lines of a file

    head –n 8 file_name   ; To read first 8 lines of a file OR head -8 file

    head -4 *.log           ; Read first 4 lines of all log files in PWD   

 

21. tail

: To read the last 10 lines in the command line  

 

Use:

    tail file_name   ; To read last 10 lines of a file

    tail –n 12 file_name   ; To read last 12 lines of a file OR tail -2 file

 

22. sort

: To sort the list 

  

Use:

    sort file_name   ; sort the content of file

    sort –n file_name   ; sorting a file which has numbers

    sort –r file_name   ; sorting  the file in reverse order

    sort –o outputfile inputfile  ; redirection of sorted output

    sort –n -k2 file_name   ; sorting  the file on basis of the nth column

 

23. unique

: An utility for filtering the repeated lines in a file

 

Use:

    unique file_name   ; will display only unique lines

    unique –c file_name   ; will tell no. of times a line has repeated

 

24. more

: Display text one screen at a time

 

Use:

    more  file_name   ; display the text in command line

                               <space> next screen,

                                    <b> back to previous screen,

                                    <enter>  next line

    more -10 file_name ; will display 10 lines at a time

    dmesg | more ; more with pipe.

 

25. less

: to read the text file in the command line

 

Use:

    less  file_name ; To view the content of a file

                                    similar to more command with some advance features

     less -N file_name ; Will show the content with line number

                                        <Enter> or Down Arrow: To move next line

                                        Up Arrow: to move up a line

                                        <space>: To move down one page

 

                                        <b>: To move up one page

26. grep

: global regular expression print

 

Use:

    grep –i  words file_name ; display the line contains searched word

    dmesg | grep sda   ; filtered the output and show only line having sda

    dmesg | grep sda –A 5 ; Display 5 lines after the matching word sda

 

27. diff or vimdiff

: find the difference between two files/dir

 

Use:

    diff file1 file2 ; To check the difference between two files

    diff dir1 dir2 ; To check the difference between contains of two dir

     A similar GUI tool is “meld”

    vimdiff f1 f2 , gvimdiff f1 f2

 

28. wc

: word count of a file

 

Use:

    wc file_name ; Newline, word and byte count in the file

    wc –l file_name ; To count total new lines in the file

    wc –w file_name ; T count total words only

    wc –c file_name ; T count total characters only

 

 

 

Category-3:  Process management commands

 

29. top or htop

: It will show the status of various resources and tasks

 

Use:

    top    ; you can see the utilization statics for resources and get PID of all running process

    htop    ; Similar to the top command but an improved version. 

30. ps

: Known as Process Status 

 

Use:

    ps            ; process for the current shell

    ps -e       ; Display all active process

    ps -ef       ; Display all active process in full format

    ps –ef | grep virtuoso   ; If the list is too big we can grep it to a specific command

31. kill

: To terminate a process

 

Use:

    kill PID   ; Killing a process by PID, PID is a numeric value.

    kill PID1 PID2 PID3    ; Kill multiple processes together. You can specify the signal name in between Kill and PID. If no signal has been specified, by default TERM signal will be sent. 

 

32. who

: Display the users who are currently logged in your Linux machine

 

Use:

    who   ; Without any argument who command will display user’s login name, terminal, login time and host

    who –q    ;Display the name of all users and total no. of users logged in

 

33. w

: information about current logged user and what they are doing

34. users

: Display the all current users name in a single line 

35. last

: it display the list of user who logged the system 

 

Use:

    last   ; If no options provided the last command displays a list of all users   logged in (and out) since /var/log/wtmp file was created

    last user_name      ;Will display the activities of a particular user only

 

36. free

: Used to check available physical memory and swap memory 

 

Use:

    free   ; Command used to check used and free memory space in KB

    free –m/g ;Space will be shown in MB or GB

    free  -s 5   ; Will update the status in every 5 seconds.

 

37. lshw

: Used to check hardware information 

 

Use:

    lshw   ; Generates detail reports about various hardware of system

    lshw –class memory  ;Details memory in the system

    lshw –class processor ; Details of processor in the system

    lshw –short –class disk   ; Details about the hard drives (network) 

 

38. lscpu

: Display information about CPU architecture

 

Use:

lscpu   ; Give the detailed information about the CPU

 

39. cat /proc/cpuinfo

: Similar information like lscpu

 

40. dmidecode

: Is a tool for dumping System Management BIOS (SMBIOS) table content in a human-readable format

 

Use:

    dmidecode   ; Gives all the hardware details

    dmidecode –t system   ; Gives the manufacturer, model no. etc details

    dmidecode –t bios ; Gives the bios information of system (/memory)

 

41. uptime

: Gives the time how long system is running

 

Use:

    uptime -p   ; Gives the duration of the system running 

 

42. reboot

: Will shutdown and restart the machine instantly

 

43. shutdown

: Can be used to shut down or restart the machine

 

Use:

    shutdown –h now    ; System will be shut down instantly

    shutdown –h +5 “message” ; System will be shut down after 5 minute

    shutdown –r +5    ; System will be restart after 5 minutes

 

 


Category-4:  Bash Environment Related Commands

 

44. date

: Will show the current date, time and of time zone

 

Use:

    date          ; Will show day, date, current time and timezone

    date –d “1990-12-31” ; Details of any specific date

    timedatectl      ; Will show details of local and universal time and timezone

    timedatectl set-time ‘2018-12-27 07:30:10’ ; to set specific date and time

    timedatectl set-time ‘Asia/Kolkata’    ; Setting time by time zone

 

 

45. cal

: Will display the calendar of current month in terminal 

 

Use:

    cal                      ; Will show calendar of current month in terminal

    cal  08 1947      ; To display a calendar of particular month and year

    cal –y 2019            ; Will show calendar of all month of a particular year

46. env

: Used to print all the current environment variables and it’s value

47. whoami

: prints the username of the current user

 

48. uname

: It provides kernel versions and other details

 

Use:

    uname          ; Without any option, will print kernel name only

    uname -a       ; Get all the information like, kernel name, version,   architecture, host name, current date and time.

 

49. hostname

: To know the hostname 

    hostname         ;It will display the hostname

    cat /etc/hostname   ;Inside the hostname file hostname is stored and  we can read and edit.

    vi /etc/hostname ;to change a new hostname edit the name here   and reboot the machine

50. echo $BASH_VERSION

: To know the BASH version. For more variables value run env command 

 

Your suggestions are most welcome in the comment section. If you wish to get this article and upcoming articles of this blog in your email, follow this blog.  
 
Thank you!

 

3 thoughts on “50 Most Useful Linux Commands for VLSI Engineers”

Leave a Comment