Basic Linux Command

pwd command:

Path of the current Working Directory

pwd

cd command:

Change Directory

  cd .. (with two dots) to move one directory up

  cd     to go straight to the home folder

  cd – (with a hyphen) to move to your previous directory

ls command:

List the content

  ls -R will list all the files in the sub-directories as well

  ls -a will show the hidden files

  ls -al will list the files and directories with detailed information like the permissions, size, owner,   etc

sudo command:

SuperUser Do (is used to access restricted files and operations)

sudo user

Working with files

cp command:

Copy a file

cp file1 file2

mv command:

Use mv to rename a file or to move the file to another directory
mv file1 file3

rm command:

Remove a directory and its files

rm -i file1
rm -rf test (the f means force and the r means recursive)

touch command: 

Create a blank new file through the Linux
touch file42

cat command : 

List the contents of a file
cat file1

head command:

View the first lines of any text file
head /etc/services
head -5 /etc/services  (last five lines)

tail command:

Display the last ten lines of a text file
tail /etc/services
tail -5 /etc/services  (last five lines)

diff command: 

Difference between files
diff file1 file2

mkdir command:

Make a new directory
mkdir dir1

rmdir command:

Delete empty directories
rmdir dir1

chmod command:

To change the read, write, and execute permissions of files and directories
chmod 777 foldername
  0 = No Permission
  1 = Execute
  2 = Write
  4 = Read

  0 = —
  1 = –x
  2 = -w-
  3 = -wx
  4 = r-
  5 = r-x
  6 = rw-
  7 = rwx

chown command:

Change or transfer the ownership of a file to the specified username
chown name foldername

ping command: 

Check your connectivity status to a server
ping localhost
ping ip-address
ping www.google.com

wget command:

Download files from the internet with the help of the wget command
wget http://website.com/files/file.zip

history command

 Is used to view the previously executed command

man command:

Display the user manual of any command
man ls

locate command: 

Locate a file, just like the search command in Windows

find command:

Similar to the locate command, using find also searches for files and directories. The difference is, you use the find command to locate files within a given directory.

grep command:

Searching plain-text data sets for lines that match a regular expression

echo command

zip, unzip command:

zip myfile.zip filename.txt
unzip myfile.zip

hostname command:

hostname –l

uname command:

Prints the kernel name

df command:

To get a report on the system’s disk space usage

du command:

Disk Usage

top command:

List of running processes and how much CPU each process uses

Basic Linux Command

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top