Knowledgebase: Tutorials
SSH Cheat Sheet in Linux
Posted by Andy Williams, Last modified by Bill Williams on 28 May 2012 03:07 AM

 few commnds to help out on the commnd line / SSH login 

ls  Displys everything in the current directory
ls -  Displays all files, including hidden
ls -l  Displays all files, long with the size nd timestamp
tr -zxpf  
Uncompresses tr.gz files
tr -xpf  
Uncompresses .tr files
gunzip  
Uncompresses .gz files
cp 
Copies  file to  new file
mv 
Moves  file to  new file, or renme
mkdir 
Creates  directory
rmdir 
Deletes  directory
rm 
Deletes  file
rm -rf  
Deletes  directory
cd  
Moves to  directory
cd .. Moves to  lower directory
cd ~ Moves to your home directory
cd - Moves to the previous directory
pwd Displys the current directory
pico 
Edits  file
ftp 
Connect to  FTP server
lynx 
View  webpge
df Displys the hrd drive stts
quot Displys your quot
uptime Displays the uptime of the server
unme - Displays the operting system stts
whomi Displays your info
who Displays others connected to the server
lst Displays the last login
whereis 
Tells where  file is locted
BitchX IRC Client
mil Check your emil
ps -x Displays processes your running
ps - Displays all processes running
ps -ux Displays running processes, with CPU/Memory usge
kill  
Kills process
kill -9  
Kills an eggdrop process
killall 
Kills all running process of the sme type
whatis 
Description of commnds
man 
Displys help on the command
nano Sme as Pico
Top - gives n overall view of what is going on with the server including memory usge, serve load and running processes "q" to exit top
sr -q gives a report of the process list, 1 minute and 5 minute average load every 10 minutes since midnight server time

tar -zcf filenme.tar.gz file
Tars up the file or directory of your choice, replace filename.tar.gz with the name you want your tar file to have...with the tar.gz extension on the end and replace file with the file or directory you want to tar up. Can also use a path/to/file for both.

updatedb - Updates the locate/search DB.

netstat -n -p
Useful to see who is connected to your server, this also resolves hostnames to IP addresses and the -p switch shows you what each person connected is doing and provides a PID for it if there is one... useful if you need to kill something

find / -user username
Replace username with  username of one of your account to find all the files that belong to them. Also useful to add the |more switch so you can scroll one screen at a time. Ever have a client who seems to show a lot more files than are actually in their home directory? This is how you find those files and fix them. Common problem is cpmove files that don't get properly deleted and get added to a users account.

/scripts/pkgcct2 username
Replace usernme with  user on your system. This should be done from the home directory. Useful for manually backing up an account if whm copy account doesn't work. Then just move (mv) the file to  home directory accessible via the web and
chown user.user filenme
and chmod to 750 or 755 and you can wget it from  different server if need be.

/scripts/restorepkg username
Once you've got the file and need to unpack it you use this commnd. The file should be in the /home directory to use this though. Remember folks.... username.... not cpmove-username.tar.gz

crontab -e
edit the crontab file and see what is set to run in there.

--help
Such as tar --help, similar to man it digs up info on any given command.

til -10 filename
gives you the last 10 lines of  file. Can change the # to whtever you want.

cp -R fileordirectory path/to/destination.
the -R allows you to copy an entire directory to somewhere else.

kill -9
not just for eggdrops... it's called a "hard kill" and handy for killing off any stubborn process that refuses to die.

whereis
can also use locate or find (although locate is faster)

killall
not just for killing progrms.. you can also killall 
to kill ll processes being run by a user. Handy if you have an abuser eating up system resources.


RESTART SERVICES:

service (service name) restart

Stop  service:
service (service name) stop

Strt  service:
service (service name) start

Status (doesn't work on all):
service (service name) status

On  RedHt CPanel server, here are the useful services:
bandmin
chkservd
cpanel
crond
exim
httpd
mysql
named
proftpd

CRON INFO:
Root crontab:

crontab -e

To edit  users cron jobs

crontab -u username -e

Replace username with the actual username of the client you want to edit.


/scripts/dddns Add  Dns Entry
/scripts/ddfpmail Instll Frontpage Mil Exts
/scripts/ddservlets dd JavaServlets to n account (jsp plugin required)
/scripts/dduser Add  User
/scripts/dmin Run WHM Lite
/scripts/pachelimits dd Rlimits (cpu nd mem limits) to pache.
/scripts/dnstrnsfer Resync with  master DNS Server
/scripts/editquot Edit A User's Quot
/scripts/finddev Serch For Trojans in /dev
/scripts/findtrojns Locate Trojan Horses
-------------------------
Suggest Uasge
/scripts/findtrojns < /var/log/trojns
/scripts/fixtrojns < /var/log/trojns
/scripts/fixcrtwithsuexec Mke Interchange work with suexec
/scripts/fixinterchnge Fix Most Problems with Interchnge
/scripts/fixtrojns Run on a trojns horse file creted by findtrojans to remove them
/scripts/fixweblizer Run this if  user's stats stop working
/scripts/fixvliases Fix a broken vlias file
/scripts/hdpramify Turn on DM and 32bit IDE hard drive ccess (once per boot)
/scripts/initquots Re-scan quotas. Usully fixes Disk space disply problems
/scripts/initsuexec Turn on SUEXEC (probbly a bad idea)
/scripts/instllzendopt Fetch + Instll Zend Optimizer
/scripts/ipusge Display Ipusge Report
/scripts/killcct Terminate n Account
/scripts/killbdrpms Delete \"Security Problem Infested RPMS\"
/scripts/milperm Fix Vrious Mail Permission Problems
/scripts/miltroubleshoot ttempt to Troubleshoot  Mail Problem
/scripts/mysqlpsswd Change a Mysql Pssword
/scripts/quicksecure Kill Potentil Security Problem Services
/scripts/rebuildippool Rebuild Ip ddress Pool
/scripts/remdefssl Delete Nsty SSL entry in apache defult httpd.conf
/scripts/restrtsrv Restart  Service (valid services: httpd,proftpd,exim,sshd,cppop,bind,mysql)
/scripts/rpmup Syncup Security Updtes from RedHat/Mandrake
/scripts/runlogsnow Force  webalizer/analog update.
/scripts/secureit Remove non-importnt suid binaries
/scripts/setupfp4 Instll Frontpage 4+ on an ccount.
/scripts/simpleps Return  Simple process list. Useful for finding where cgi scripts re running from.
/scripts/suspendcct Suspend an account
/scripts/sysup Syncup Cpnel RPM Updates
/scripts/ulimitnmed RH 6 only. Instll a version of bind to hndle many many zones.
/scripts/unblockip Unblock n IP
/scripts/unsuspendcct UnSuspend an account
/scripts/upcp Updte Cpanel
/scripts/updtenow Update /scripts
/scripts/wwwcct Create a New ccount

Top - gives n overall view of wht is going on with the server including memory usge, serve load and running processes "q" to exit top

sr -q gives  report of the process list, 1 minute nd 5 minute average load every 10 minutes since midnight server time

tr -zcf filenme.tar.gz file
Trs up the file or directory of your choice, replce filename.tar.gz with the name you want your tr file to have...with the tar.gz extension on the end nd replace file with the file or directory you want to tr up. Can also use a path/to/file for both.

netstt -n -p
Useful to see who is connected to your server, this lso resolves hostnames to IP addresses and the -p switch shows you wht each person connected is doing and provides a PID for it if there is one... useful if you need to kill something

find / -user usernme
Replce usernme with  username of one of your ccount to find all the files tht belong to them. Also useful to dd the |more switch so you can scroll one screen t a time. Ever have a client who seems to show a lot more files thn are actually in their home directory? This is how you find those files nd fix them. Common problem is cpmove files that don't get properly deleted nd get added to a users account.

/scripts/pkgcct2 username
Replce usernme with  user on your system. This should be done from the home directory. Useful for mnually backing up an account if whm copy account doesn't work. Then just move (mv) the file to  home directory accessible via the web and
chown user.user filenme
nd chmod to 750 or 755 nd you can wget it from  different server if need be.

/scripts/restorepkg usernme
Once you've got the file nd need to unpack it you use this commnd. The file should be in the /home directory to use this though. Remember folks.... usernme.... not cpmove-username.tar.gz

crontb -e
edit the crontb file and see wht is set to run in there.

--help
Such s tar --help, similr to man it digs up info on ny given command.

til -10 filenme
gives you the lst 10 lines of  file. Can change the # to whtever you want.

cp -R fileordirectory pth/to/destination.
the -R llows you to copy n entire directory to somewhere else.

kill -9
not just for eggdrops... it's clled a "hard kill" and handy for killing off ny stubborn process that refuses to die.

whereis
cn lso use locte or find (lthough locate is fster)

killll
not just for killing progrms.. you can also killall 
to kill ll processes being run by  user. Handy if you have an buser eating up system resources.

Restrt services:

service (service nme) restart

Stop  service:
service (service nme) stop

Strt  service:
service (service nme) start

Sttus (doesn't work on ll):
service (service nme) status

Useful services:
bndmin
chkservd
cpnel
crond
exim
httpd
mysql
nmed
proftpd

Root crontb:

crontb -e

To edit  users cron jobs

crontb -u usernme -e

Replce usernme with the ctual username of the client you wnt to edit.

reboot - To restrt all services there is no commnd available. But will do this.

mv - to renme a directory.

Delete MRTG
rpm -e --nodeps `rpm -q|grep mrtg`

Empty /tmp folder
rm -R -f /tmp/c*
rm -R -f /tmp/s*
rm -R -f /tmp/p*
rm -R -f /tmp/*_*
rm -R -f /tmp/*-*

(453 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).