There was a problem loading the comments.

SSH Cheat Sheet in Linux

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
A few commands to help out on the command line / SSH login

ls - Displays everything in the current directory
ls -a - Displays all files, including hidden
ls -la - Displays all files, long with the size and timestamp
tr -zxpf - Uncompresses tr.gz files
tr -xpf - Uncompresses .tr files
gunzip - Uncompresses .gz files
cp - Copies a file to new file
mv - Moves file to a new file, or rename
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 - Displays the current directory
pico - Edits file
ftp - Connect to FTP server
lynx - View webpage
df -c Displays the hard drive stats
quota - Displays your quota
uptime - Displays the uptime of the server
uname - Displays the operating system stats
whoami - Displays your info
who - Displays others connected to the server
last - Displays the last login
whereis - Tells where file is located
BitchX IRC Client
mail - Check your email
ps -x Displays processes your running
ps - Displays all processes running
ps -aux Displays running processes, with CPU/Memory usage
kill - Kills process
kill -9 - Kills an eggdrop process
killall - Kills all running process of the same type
whatis - Description of commands
man - Displays help on the command
nano - Same as Pico
top - gives an overall view of what is going on with the server including memory usage, serve load and running processes "q" to exit top

sar -q
Gives a report of the process list, 1 minute and 5 minute average load every 10 minutes since midnight server time

tar -zcf filename.tar.gz filename2
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 username 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 filename
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 command. 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.

tail -10 filename
gives you the last 10 lines of file. Can change the # to whatever 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 programs.. you can also killall to kill all processes being run by a user. Handy if you have an abuser eating up system resources.


Restart service:
service (service name) restart

Stop service:
service (service name) stop

Start service:
service (service name) start

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


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


To edit root cron jobs
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/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 apache.
/scripts/dnstrnsfer Resync with master DNS Server
/scripts/editquota Edit A User's Quota
/scripts/finddev Search For Trojans in /dev
/scripts/findtrojans Locate Trojan Horses
-------------------------
Suggest Usage
/scripts/findtrojans < /var/log/trojans
/scripts/fixtrojans < /var/log/trojans
/scripts/fixcrtwithsuexec Make Interchange work with suexec
/scripts/fixinterchange Fix Most Problems with Interchange
/scripts/fixtrojans Run on a Trojans horse file created by findtrojans to remove them
/scripts/fixweblizer Run this if user's stats stop working
/scripts/fixvaliases Fix a broken alias file
/scripts/hdpramify Turn on DM and 32bit IDE hard drive access (once per boot)
/scripts/initquotas Re-scan quotas. Usually fixes Disk space display problems
/scripts/initsuexec Turn on SUEXEC (probably a bad idea)
/scripts/installzendopt Fetch + Install Zend Optimizer
/scripts/ipusage Display Ipusage Report
/scripts/killacct Terminate n Account
/scripts/killbdrpms Delete \"Security Problem Infested RPMS\"
/scripts/mailperm Fix Various Mail Permission Problems
/scripts/mailtroubleshoot attempt to Troubleshoot Mail Problem
/scripts/mysqlpsswd Change a Mysql Password
/scripts/quicksecure Kill Potential Security Problem Services
/scripts/rebuildippool Rebuild Ip address Pool
/scripts/remdefssl Delete Nasty SSL entry in apache default httpd.conf
/scripts/restartsrv 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 account.
/scripts/simpleps Return Simple process list. Useful for finding where cgi scripts re running from.
/scripts/suspendacct Suspend an account
/scripts/sysup Syncup Cpanel RPM Updates
/scripts/ulimitnmed RH 6 only. Install a version of bind to handle many many zones.
/scripts/unblockip Unblock n IP
/scripts/unsuspendcct UnSuspend an account
/scripts/upcp Update Cpanel
/scripts/updatenow Update /scripts
/scripts/wwwacct Create a New account

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

sar -q - gives 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 tr 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.

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 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 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/pkgacct2 username
Replace username 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 filename 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 nd need to unpack it you use this command. 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 s tar --help, similar to man it digs up info on any given command.

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

cp -R file-or-directory 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 programs.. you can also killall to kill all processes being run by user. Handy if you have an user eating up system resources.

Restart services:
CentOS 6: service (service name) restart
CentOS 7: systemctl restart (service name)

Stop service:
CentOS 6: service (service name) stop
CentOS 7: systemctl stop (service name)

Start service:
CentOS 6: service (service name) start
CentOS 7: systemctl start (service name)

Status (doesn't work on ll):
CentOS 6: service (service name) status
CentOS 7: systemctl status (service name)

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

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.
reboot - To restart all services there is no command available. But will do this.

mv - to rename 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/*-*


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net