Thursday, April 29, 2010

Various linux commands

grep -irl * [i=case sensitive,allow both case. r=recursive, l=list out] // search domain in /hsphere/local/config/httpd/sites/

1.check php version: php -v

2.check which php: php -i // php -i |grep php.ini

3./usr/local/cpanel/logs // logs of cpanel

4./var/cpanel/userdata // gives the user data.

5.ctrl+] // to come out from established connection

Then q enter.

7.Search customer by name or by email id:-

8.vps # vzctl enter (id of domain) // to go to root of particular domain.

9.For neural customer search from database the details. Take user & password and login from site. /dir && command /etc | pr -T9 -W$COLUMNS // print contents in 9 T9=9 column W=width.

12.find -name '*.[ch]' | xargs grep -E 'expr' //Search 'expr' in this dir and below. See also findrepo

13.find -type f -print0 | xargs -r0 grep -F 'example' //Search all regular files for 'example' in this dir and below

14.find -maxdepth 1 -type f | xargs grep -F 'example' //Search all regular files for 'example' in this dir

15.find -type f ! -perm -444 ///Find files not readable by all (useful for web site)

16.find -type d ! -perm -111 //Find dirs not accessible by all (useful for web site)

17.grep --color kamal /etc/passwd //Highlight occurances of regular expression in dictionary

18. gpg -c file //Encrypt file

gpg file.gpg //Decrypt file

19. scp -p -r $USER@$HOST: file dir/ // Copy with permissions to $USER's home directory on $HOST

20.ssh -g -L 8080:localhost:80 root@$HOST //Forward connections to $HOSTNAME:8080 out to $HOST:80

ssh -R 1434:imap:143 root@$HOST //Forward connections from $HOST:1434 in to imap:143


wget -c //Continue downloading a partially downloaded file

wget -r -nd -np -l1 -A '*.jpg' //Download a set of files to the current directory


echo 'wget url' | at 01:00 //Download url at 1AM to current dir

wget --limit-rate=20k url //Do a low priority download (limit to 20KB/s in this case)

wget -o log url // faults r stored in log file . log=/x.txt

wget --dns-timeout=seconds url

--connect-timeout=seconds url

--read-timeout=seconds url

--limit-rate=amount url

--user=user url

--password=password url

23. ethtool eth1 // show status of ethernate 0 1

24.ip link show //List network interfaces


ethtool eth0 //Show status of ethernet interface eth0

ethtool --change eth0 autoneg off speed 100 duplex full //Manually set ethernet interface speed

iwconfig eth1 //Show status of wireless interface eth1

iwconfig eth1 rate 1Mb/s fixed //Manually set wireless interface speed

iwlist scan //List wireless networks in range

ip link set dev eth0 name wan //Rename interface eth0 to wan

ip link set dev eth0 up //Bring interface eth0 up (or down)

ip addr show //List addresses for interfaces

ip addr add brd + dev eth0 //Add (or del) ip and mask (

ip route show //List routing table

ip route add default via //Set default gateway to


netstat -tupl //List internet services on a system with it we can search anything by grep

netstat -tup //List active connections to/from system


cal -3 // Display a calendar

cal 9 1752 // Display a calendar for a particular month year

date -d fri //What date is it this friday. See also day

28. ls -lSr ls -lS // show the file order in size.

29. df -h Show free space on mounted filesystems

• df -i Show free inodes on mounted filesystems

• fdisk -l Show disks partitions sizes and types (run as root)

30.lsof -p $$ //List paths that process id has open

tcpdump not port 22 //Show network traffic except ssh. See also tcpdump_not_me

ps -e -o pid,args --forest //List processes in a hierarchy

ps -p 1,2 //List info for particular process

watch -n.1 'cat /proc/interrupts' // Watch changeable data continuously IDs


31.• uname -a //Show kernel version and system architecture

• head -n1 /etc/issue //Show name and version of distribution

• cat /proc/partitions //Show all partitions registered on the system

• grep MemTotal /proc/meminfo //Show RAM total seen by the system

• grep "model name" /proc/cpuinfo //Show CPU(s) info

• lspci -tv //Show PCI info

• lsusb -tv //Show USB info

• mount | column -t //List mounted filesystems on the system (and align output)

• grep -F capacity: /proc/acpi/battery/BAT0/info // Show state of cells in laptop battery

# dmidecode -q | less //Display SMBIOS/DMI information

# smartctl -A /dev/sda | grep Power_On_Hours //How long has this disk (system) been powered on in total

# hdparm -i /dev/sda //Show info about disk sda

# hdparm -tT /dev/sda //Do a read speed test on disk sda

# badblocks -s /dev/sda


32. pg

Used to display data one page (screenful) at a time. The command can take a number of filenames as arguments.

Pg [option] [filename] [filename2]…..


Sort is a utility program that can be used to sort text files in numeric or alphabetical order

Sort [filename]

34.& - run a program in background mode.


35. Get back windows admin password: "C:\Program Files\SWsoft\Plesk\admin\bin\plesksrvclient.exe" –get

1 comment:

  1. Bluehost is ultimately one of the best hosting provider for any hosting services you might need.