Technical Stuff

Start from basics

Top Linux Commands

Top Linux Commands
Top Linux Commands
4.8 (95.56%) 18 votes

Hi All ! Today we are going to discuss regarding the top Linux Commands used in mostly each and every field of IT.

The most interesting thing about Linux commands is, which i feel is that.You just have to hit one command and your work is done.

So, this blog is very useful for the freshers professional and as well as linux administrator.

Following are some of the most important linux Commands used in the IT industries.

Command for going directly to root directory of user home directory or going one step back -

  1. cd

This command is used to jump directly to home directory of the user

Suppose, your user is abc, then it will be /home/abc

  1. cd ..

This command is use to come back one step behind

Suppose, You are in /app/jboss location. Using this linux command, you will come back to jboss directory.

  1. cd /

This command is use to go directly to root directly.

 

Command delete files and directory

  1. rm

This command is use to delete the files.

For Ex : If you want to delete a file called ‘abc.txt’

Command : rm abc.txt

  1. rm –rf

This command is use to delete the folder or directory.

For Ex : If you want to delete a directory called ‘abc’

Command : rm –rf abc

 

 Commands for listing

  1. ll

This command is use to list all the files from the directory vertically.

Suppose, we are in /app/jboss directory. Using this command it will list all files from jboss directory vertically.

  1. ls

This command is use to list all the files from the directory horizontally.

Suppose, we are in /app/jboss directory. Using this command it will list all files from jboss directory horizontally.

 

  1. ls –a

This command is use to list all files including hidden files.

 

Copy Command

  1. cp

This command is use to copy files from one location to another.

Suppose, In /apps directory there is one file called “Prasad.txt” and you have copy that file to /etc/abc/apache location

Go to /apps directory,

Command : cp Prasad.txt /etc/apps/apache

OR

If you are in /etc/abc/apache location

Command : cp /apps/Prasad.txt .

In this . (dot) represents the current location

  1. cp –r

This Linux command is use to copy files as well as directories from one location to another.

Suppose, In /apps directory there is one directory called “Prasad” and you have copy that directory to /etc/abc/apache location

Go to /apps directory,

Command : cp -r Prasad /etc/apps/apache

OR

If you are in /etc/abc/apache location

Command : cp –r /apps/Prasad .

In this . (dot) represents the current location

 

Move and Rename command

  1. mv

This command is used in 2 ways.

First, to move file from one place to another.

Suppose, In /apps directory there is one file called “Prasad.txt” and you have copy that file to /etc/abc/apache location

Go to /apps directory,

Command : mv Prasad.txt /etc/apps/apache

Secondly, Its is used to rename the file

Suppose, You want to rename Prasad.txt to Prasad123.txt

Command : mv Prasad.txt Prasadq123.txt

 

Command for extraction and Zipping

  1. gzip & zip

This command is use to zip the file.

gzip Prasad.txt

Prasad.txt is the file to be zipped.

  1. gunzip & Unzip

This command is use to unzip the file.

gunzip Prasad.txt

Prasad.gzip is the file to be unzipped.

  1. tar

This command is use to zip the file.

tar –cvzf Prasad.tar.gz Prasad

Prasad.tar.gz – Name to be given after zipping the file.

Prasad – folder name to be zipped

  1. untar

This command is use to unzip the file.

tar –xvzf Prasad.tar.gz Prasad

Prasad – Name to be given after unzipping the file.

Prasad.tar.gz – folder name to be unzipped

 

Commands for giving permissions

  1. Chmod –R

This command is use to give permission to any file.

Syntax : chown <owner_name><Filename>

For Example : chmod –R 755 <File name>– This command is use to always give read and execute permission to everyone and only write permission to owner

  1. Chown

This command is use to give permission to any directory or file.

 

  1. Sudo

This is like a king, King of kingdom. You have all the right and you can do anything.

  1. Cat /proc/cpuinfo

This command is use to display CPU info.

  1. Pwd

This command is use print the location of the directory where you are presently located.

For Example, If you are in /apps/jboss location, Using this command , it will show you this path. i.e. /apps/jboss

  1. mkdir

These command is use to make the directory.

Suppose, If you have to make a directory called psd

Command : mkdir psd

  1. touch

These command is use to create new file.

If you want to create a file name ‘psd.txt’

Command : touch psd.txt

  1. man

If you don’t know of any command then hit this command.

Syntax – man <command name>

  1. history

These command is use to check the history of all commands used.

Command : history

If you want to specifically find ‘start’ command from history.

Command : history | grep start

  1. Uname

uname -a

Print System information

uname –s

It prints kernel name

  1. diff

This command is use to check the difference of two files.

Suppose, Two file name abc.txt and psd.txt and check difference in file.

Command : diff abc.txt psd.txt

 

  1. cat

This command is use to open the file.

If you want to open psd.txt

Command : cat psd.txt

  1. grep

This command is use for searching.

In a file, if you want to search a specific word called ‘datasource’. Then open the file search the specific word using “|” (Pipe) is use to consolidate two commands.

Command : cat psd.txt | grep datasource

  1. find

If you don’t know regarding file location, then this command is very useful.

Command : find / -name psd.txt

/ - location where to start.

Psd.txt – filename.

------------------------------------------------------------------------------

Linux command used by Middleware Admin

  1. Kill all

This command is used to kill or shut all the processes.

Command : kill –all

Note : Think twice before you use this command.

  1. Kill -9

This command is use to kill the specific process

Command : kill -9 pid

  1. Ps

This command is use to find processes id and details of process.

  1. To check the service command.

Suppose, if you want to find pid of java

Command : ps –aef | grep java

  1. To check logs in running fashion

Command : tail –f log.txt

  1. top

This command is use to check cpu, Memory of specific process or service and load of server

  1. df –h

This command is use to check the physical space of all mount points.

  1. free –m

This command is use to check the free memory in MB

  1. Free –g

This command is use to check the free memory in GB

  1. Free –k

This command is use to check the free memory in KB

  1. Who –b

This command is use to check the last server rebooted details.

  1. sar

This command is used to check full day CPU Utilization of server

sar –r

This command is used to check full day Memory Utilization of server

 

  1. Uptime

This command is use to see the uptime of server. From how many days server is UP and Running.

Linux commands used by Network Admin

  1. Netstat

This command in simple way to review each of your network connection and open sockets.

This output is very useful in webserver troubleshooting.

  1. Ping

This command is use to simply verify the server is communicating over the network.

Command : ping 172.34.34.21

  1. nslookup

It is a program to query internet domain name server.

For Example – nslookup technicalstuff.in

  1. telnet

This command shows the connectivity between the two hosts.

Example : telnet technicalstuff.in 443

You can take any port and check and if you are not getting the port output successful. Then, you have to open the port.

  1. nz

This is same as telnet. If telnet is not working in your organization. Then you can use this command.

  1. tarceroute

This command is use to find route packets network host.

For Example – traceroute technicalstuff.in

  1. ifconfig

This command is to find ip address of server.

  1. Dig

It performs DNS Lookups and display the answer that are return from nameserver.

  1. W

This command is use to check how users are login to server and what processes they are holding.

  1. scp

This command is use to securely copy file or directory from one server to another.

scp $filename [email protected]:/$PATH

Command : scp psd.txt [email protected]:/apps/jboss

Above command show,

Psd.txt – filename.

User – Prasad

Target Host – 172.67.21.12

Path - /apps/jboss

  1. nmap

This is one of the most important command which shows the port is opened or not.

Syntax : nmap $SERVER_NAME

  1. ifup eth0

This Linux command is use to enable the network interface with Ethernet interface parameter

  1. ifdown eth0

This command is use to disable network interface with Ethernet interface parameter.

  1. tcp –i eth0

This command is use to capture packet from specific interface.

This are the top Linux Commands. If you want me to add more complicated Linux Commands. Do comment down below.

Thank You !

Happy Learning !!!

If you have doubt or queries, you can definetely comment us or can mail us on [email protected]

If you have any Recommendation for future blog, You can email us on [email protected]

Top Searches :

  1. Introduction to Linux
  2. Websphere Hack
  3. Installation and configuration of Apache 2.2 on Linux
  4. DB Auto Re-connect.
  5. Redirection in Jboss.
  6. SSL Implementation in Jboss
  7. Best SSL Guide.
  8. Types of SSL.
  9. Best Jboss Server Security Guide.
  10. Introduction to hardening in Middleware.
  11. Hardening In Jboss EAP 5.1
  12. Enable TLS1.2 in Jboss EAP 7

 

4 thoughts on “Top Linux Commands

Leave a Reply

%d bloggers like this: