Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Linux Basic Commands (Part 2/15)

November 13, 2020 By Ashish Vara

Linux Basic Commands

Linux supports both GUI (Graphical User Interface) and CLI (Command Line Interface) environments. GUI is more user friendly for users and it’s easy to point, click and drag without any confusion. You can create folder, file and various operations as per your need and work upon them  like window operating system. Traditional UNIX environment supports CLI but not GUI.

Command Line Interface is a terminal where you can enter the command to tell computer what to do. You can create file, folder and various operations by entering command in CLI terminal and it is faster and more powerful than GUI. Various Linux distributions make use of similar commands. You  need to read various commands before working in Linux with CLI.

No I am going to explain the basic command with Ubuntu 14.04 LTS desktop environment. First search the Terminal from your Search Bar or open the terminal from keyboard shortcut Ctrl+Alt+T.

List of Basic Command:

pwd ­- Print Working Directory

Directory is not a new thing but it is same as folder in windows operating systems. In Linux, folders are known as directory.

Pwd command prints the current working directory on terminal.

[email protected]:~$ pwd          // Press the enter button after entering command in terminal

/home/ashish                            // path and name of working directory

ls – Listing of Current Directory

Ls command displays the list of current directory and files in working directory.

For example, currently I am in directory named ashish and I entered command ls as following:

[email protected]:~$ ls

the list of directory and file will be displayed on terminal after entering ls command as follows:

core     Documents  EG                ldd3   Pictures  sketchbook  Videos

Desktop  Downloads  examples.desktop  Music  Public    Templates

cd – for navigation change Directory

Cd command changes the directory from current directory located inside the current directory. You can enter the following cd command in the directory:.

Syntax of command:  cd<space>name of directory

For example, currently I am in directory named ashish and I entered command cd as following for changing the directory named EG which is located inside ashish:

[email protected]:~$ cd EG

See, now you change the directory from ashish to EG.

[email protected]:~/EG$

Note: if you tried to change directory which is not located inside current working directory, you cannot change the directory.

Suppose, I want to change directory from EG to Pictures (Pictures directory located in ashish, not in EG directory)

[email protected]:~$ cd Pictures

you can see the following messages on terminal:

bash: cd: Pictures: No such file or directory

Here question arises as to how one can enter another directory (which is outside of current directory) from current directory. Solution is that you need to exit from current directory and then enter in another directory.

You can exit and go to the previous directory using following command:

 Syntax of command:  cd<space><dot><dot>

Suppose, I want to change directory from EG to Pictures (Pictures directory located in ashish, not in EG directory). So first I will go into previous directory.

[email protected]:~/EG$ cd ..

Now you are exited from current directory named EG and you are in directory named ashish.

[email protected]:~$

Next enter the new directory named Pictures.

[email protected]:~$ cd Pictures

See, now you change the directory from ashish to Pictures.

[email protected]:~/Pictures$

If you want to go to the root directory (like C drive in window OS), use the following command:

Syntax of command:  cd<space><forward slace>

[email protected]:~$ cd /

Now you are in the root directory. Display the following line on terminal:

[email protected]:/$

Touch- Create a new file

Syntax of command:  touch<space><file name>

For example,

You can create a new text file named test.txt in main ashish directory. Enter the following command:

[email protected]:~$ touch test.txt

Now you can go to ashish directory and check it.

cp – Create same copy of original file in same directory or any another directory.

Use the following command for createing same copy of original file in the same directory.

Syntax of command:  cp<space><file name><space><copy file name>

Note: file name and copy file name are different. You cannot create a copy of the file with same the name in same folder.

For example,

You want to create copy of test.txt file in same directory named testcopy.txt. Enter the following command:

[email protected]:~$ cp test.txt testcopy.txt

Now you can go to ashish directory and find the copy of test.txt file.

Use the following command for creating same copy of original file in another directory.

Syntax of command:  cp<space><file name><space><Path name>

Path name – where we want to create file

For example,

If you want to create copy of test.txt file in another directory named Music, enter the following command:

[email protected]:~$ cp test.txt /home/ashish/Music

Now you can go to ashish/Music directory and find the copy of test.txt file.

mv – move file or directory from source to destination

Syntax of command:  mv<space><file or directory- source ><space><destination path>

For example,

You want to move test.txt file from directory named ashish to directory named Garage. Enter the following command:

[email protected]:~$ mv test.txt /home/ashish/Garage

You can also rename the file name using mv command as following:

[email protected]:~$ mv test.txt renametest.txt

More Basic Commands

This command renames the file test.txt with new name renametest.txt.

rm – Remove or delete file from directory

Syntax of command:  rm<space><file name>

For example,

If you want to remove testcopy.txt file from directory named ashish, enter the following command:

[email protected]:~$ rm testcopy.txt

mkdir – create new directory

Syntax of command:  mkdir<space><Directory name>

For example,

To create new directory named Garage, enter the following command:

[email protected]:~$ mkdir Garage

Enter the following command if you want create subdirectory in recursively manner:

Syntax of command:  mkdir<space><hyphen>p<Subdirectory name>

For example,

To create new directory named folder1 and inside folder1 create folder2,. enter the following command:

[email protected]:~$ mkdir -p folder1/folder2

rmdir – remove existing directory

Syntax of command:  rmdir<space><Directory name>

Note: You can remove or delete the directory if it is empty. It cannot delete if the directory contains some files or another directory.

For example,

to remove directory named Garage,. enter the following command:

[email protected]:~$ rmdir Garage

Enter the following command if you want to remove or delete directory which contains some files or another directory:

Syntax of command:  rm<space><hyphen>r<space><Directory name>

r- Recursive means repeat the procedure as enter directory inside enter another directory and go on.(Didn’t get the line)

For example,

To remove directory named Garage which contains some file or another directory,. enter the following command:

[email protected]:~$ rmdir -r Garage

su – change super Id or enter as superuser

Su command is used for sudo in order to enter or login as root or Superuser. Simple user cannot enter or access as a superuser. Superuser or root permission is required if you want to install some application or some configuration. You can enter as superuser using following command:

[email protected]:~$ su                          //after entered su, terminal ask for enter password

Password:

It is password protected so you need to enter password which you had set as superuser password during configuration.

exit – out or exit from superuser or root

Superuser can exit or logout by entering exit command.

[email protected]:~# exit                          //after entered exit, terminal display logout message

logout

man – manio or provide the all information regarding specific command.

If you don’t know about the use of a particular command, terminal provides the facility with man command which helps to find all the information regarding command.

Syntax of command:  man<space><Command name>

clear – clear the command line interface terminal

It is normal command to clear the screen means CLI terminal.

date – Provide the system date with time

[email protected]:~$ date

Terminal display the system date with time as following:

Tue Jan 19 17:26:39 IST 2016

history – display the history of entering command

It displays the list of previously entered command.

ifconfig – Show the IP address of system, internet, Ethernet, mask etc.

 ifconfig displays the information of IP address related to system, Ethernet, mask etc. and package information.

uptime – display current time

 uptime command displays the information of current time, number of users and system load.

 cal – Display the calendar of current month

cal command displays the calendar of  running month. You can show the year’s calendar using cal command.

Displays the calendar of current month by following syntax:

Syntax of command:  cal

Displays the calendar of any year by following syntax:

Syntax of command:  cal<space><year>

For example,

[email protected]:~$ cal 2016

It displays the calendar of whole 2016 year.

whoami – print effective user ID

It displays the Login user ID.

w – Display the information that who is online

 It displays the information that who is online and what they are doing.

uname – Display System information

It displays the information of kernel name, distribution, version etc.

For example,

Enter the following command if you want to display the name of kernel:

[email protected]:~$ uname

Output is:

Linux

Enter the following command if you want to display all system information:

Syntax of command:  uname<space><hyphen>a

[email protected]:~$ uname -a

Terminal displays the following information:

Linux ubuntu 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:45:15 UTC 2015 i686 i686 i686 GNU/Linux

free – Display the amount of used memory and free memory

It displays the information of total memory, free memory and usage memory. It also displays cached, buffer, shared and swap memory.

Related Articles Read More >

Screenshot of Raspbian OS on Raspberry Pi
RPi Python Programming 03: Raspberry Pi as Linux System
Raspberry Pi Models
RPI Python Programming 02: Raspberry Pi Models
Raspberry Pi 4
RPi Python Programming 01: Introduction to Raspberry Pi 4
RPi Python Programming 05: Introduction to Python

Featured Tutorials

  • Screenshot of Raspbian OS on Raspberry Pi RPi Python Programming 03: Raspberry Pi as Linux System
  • Raspberry Pi Models RPI Python Programming 02: Raspberry Pi Models
  • Raspberry Pi 4 RPi Python Programming 01: Introduction to Raspberry Pi 4
  • RPi Python Programming 05: Introduction to Python
  • RPi Python programming 04 RPi Python programming 04: Setting up Raspberry Pi Linux computer
  • Python Basics RPi Python Programming 06: Python basics

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

Recent Articles

  • New Vishay Semiconductors increase efficiency of high-frequency applications
  • TI launches industry’s top wireless battery-management solution
  • AVX releases new series of embedded, highly sensitive Wi-Fi antennas
  • Nuvoton offers a secure storage MCU for multi-segments
  • Refrigerator Compressor Design Achieves High Energy Efficiency Ratings Using a Digital Signal Controller (DSC)
...

RSS EDABOARD.com Discussions

  • Rippe current rating of aluminium electrolytic capacitor is very low.
  • Why do some op amps have a higher GBW than what the unity gain-bandwidth is?
  • Stacked Diodes ?
  • dsPIC33f ADC reading voltage help
  • What the best way to store data of size ( 90,000 * 32) bit (taken from a text file) using VHDL?

RSS Electro-Tech-Online.com Discussions

  • Engine Temperature using an AD590 on the Oil Pressure Wire to the engine
  • Automotive 6 Volt Generator Transistor Voltage Regulator
  • Jon's Imaginarium - Microchip FilterLab Program and Graph Paper Printer Program by Dr. Philippe Marquis
  • Touch circuit sound, led. 555 timer
  • Dust extractor remote switch
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering