Linux Commands

File Commands

ls  > Directory Listing

[root@mongodb ~]# ls

Ls –al > Formatted listing with hidden files.

[root@mongodb ~]# ls -al

ls  -lt > Sorting the Listing by time modification

[root@mongodb ~]# ls -tl

Cd >  change the directory

[root@mongodb ~]# cd dir

Cd dir > change directory ( cd Documents)

[root@mongodb ~]# cd Documents

Pwd > Current Working Directory

[root@mongodb ~]# pwd

mkdir dir > suppose here I have mention to create a directory

[root@mongodb ~]# mkdir unix-linux-testing

 Cat  >file >  cat >file.txt

[root@mongodb ~]# cat > querypanel.txt

Hi we are here to show you real time Working Experience

[root@mongodb ~]# cat querypanel.txt  ( it will display the content in the text file)

More file.txt >   ( it will also display the content in the text file)

[root@mongodb ~]# more querypanel.txt

Head filename>

It will only display First 10 lines

[root@mongodb ~]# head query.txt

Tail filename>

It will display last 10 lines of the files

[root@mongodb ~]# tail query.txt

Touch filename > create directory

[root@mongodb ~]# touch querypanel

rm file> Deleting the file

[root@mongodb ~]# rm querypanel.txt

rm -r dir> remove thedirectory

[root@mongodb ~]# rm -r qp

rm -f file> fource to remove file

[root@mongodb ~]# rm -f query.txt

rm -rf dir > fource to remove directory

[root@mongodb ~]# rm -rf querypanel

Process management

Ps > display the current working process

[root@mongodb ~]# ps

Top > display all running process

[root@mongodb ~]#  top

kill pid> kill process suppose PID is 216

so here kill 216 

[root@mongodb ~]# kill 216

killall proc> kill all the process name

[root@mongodb ~]# killall deferwq

File permission

Chmod> file permission

Chmod 775 filename

Chmod 777 filename

Change the permission of file to octal,which can be found separately for user,group,world by adding,

• 4-read(r)

• 2-write(w)

• 1-execute(x)

Chmod  –r

Chmod  –w

Chmod  -x

                                                                                System Info

Date> Show the current date and time

Cal> Show this month’s calendar

w>  Display who is on line

whoami > Who you are logged in as

[root@mongodb ~]# whoami

uname –a>  Show kernel information

[root@mongodb ~]# uname -a

cat /proc/cpuinfo>  Cpu information

[root@mongodb ~]# cat /proc/cpuinfo

df > Show the disk usage

[root@mongodb ~]# df

du > Show directory space usage

[root@mongodb ~]# du

Free> Show memory and swap usage

[root@mongodb ~]# free

Whereis>  Show possible locations

Which>  Show which applications will be run by default

                                                                                Network

Ifconfig > internet protocol details

[root@mongodb ~]# ifconfig -a

mongodb ~]# ifconfig

Ping>   ping host Ping host

[root@mongodb ~]# ping google.com

dig domain>  Get DNS information for domain

[root@mongodb ~]# dig domain

wget file>  Download file

[root@mongodb ~]# wget https://xampp.com

wget -c file Continue a stopped download

 [root@mongodb ~]# wget -c file Continue a stopped download

IMPORTANT COMMANDS

ps –eaf | grep processed id>

[root@mongodb ~]# ps -eaf | grep 221

ps –eaf>

[root@mongodb ~]# ps -eaf

ls –l > list files format

[root@mongodb ~]# ls -l

Ls –rtl > list directory long format

ot@mongodb ~]# ls –rtl

Start with vi <filename>

[root@mongodb ~]# vi /etc/hosts

Edit modes: These keys enter editing modes and type in the text of your document.

i —Insert before current cursor position

I —Insert at beginning of current line

a —Insert (append) after current cursor position

A —Append to end of line

r —Replace 1 character

R —Replace mode

<ESC> —Terminate insertion or overwrite mode

Deletion of text

x —Delete single character

dd —Delete current line and put in buffer

ndd —Delete n lines (n is a number) and put them in buffer

J —Attaches the next line to the end of the current line (deletes carriage return).

su username>

[root@mongodb ~]# su oracle

grep> – Search files for text patterns

awk> – Pattern-matching language

[root@mongodb ~]# awk

ps –ef | grep smon> List available instances on a server

[root@mongodb ~]# ps -ef | grep smon

ps -ef | grep listener | grep -v grep> List available listeners on a server:

[root@mongodb ~]# ps -ef | grep listener | grep -v grep

Reboot > restart system.

[ root@mongodb ~]# reboot

ip route > Check gateway information

[ root@mongodb ~]# ip route

l -a > list all file including hidden

[ root@mongodb ~]# l -a

including . is hidden files

Grep > Used to search the Specific file

  • chown : Used to change the owner of file.
  • chmod : Used to modify the access/permission of a user.

History >

[ root@mongodb ~]# history

One thought on “Linux Commands

Leave a Reply

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