Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Linux Basic Commands (Part 2/15)

By Ashish Vara November 13, 2020

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.

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ cd EG

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

ashish@ubuntu:~/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)

ashish@ubuntu:~$ 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.

ashish@ubuntu:~/EG$ cd ..

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

ashish@ubuntu:~$

Next enter the new directory named Pictures.

ashish@ubuntu:~$ cd Pictures

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

ashish@ubuntu:~/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>

ashish@ubuntu:~$ cd /

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

ashish@ubuntu:/$

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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ mv test.txt /home/ashish/Garage

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

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ 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.

root@ubuntu:~# 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

ashish@ubuntu:~$ 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,

ashish@ubuntu:~$ 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:

ashish@ubuntu:~$ uname

Output is:

Linux

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

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

ashish@ubuntu:~$ 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.

You may also like:


  • What is the LoRaWAN network and how does it work?

  • What are the different EV charging protocols?

  • What is the Modbus protocol and how does it work?

  • What is an Actuator Sensor Interface (AS-i)?

  • What is a Robot Operating System (ROS)?

  • What is FreeRTOS?

Filed Under: Featured Contributions, Tutorials

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Industrial Relay Board Design for Motorcycle Use
  • Safe Current and Power Density Limits in PCB Copper(in A/m² and W/m³) simulation
  • The Analog Gods Hate Me
  • Egs002
  • Help with hall effect sensors for a milwuakee impact driver

RSS Electro-Tech-Online.com Discussions

  • Raise your hand if your car had one of these:
  • Simple LED Analog Clock Idea
  • Kawai KDP 80 Electronic Piano Dead
  • Tektronix 2235 channel 1 trace unstable
  • How to make string LEDs?

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cm³ density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products
  • Amphenol RF introduces FAKRA to SMA adapters with 4 GHz operating frequency

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 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

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe