Wednesday, April 14, 2010

Common Linux Commands I Use

Processes

To view current processes running on the system use the following commands:

ps auxw # USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ps auxw | grep | sort –n

Netstat

To view open connections and ports use netstat.

Netstat –nape

Outputting to Null

> /dev/null

TAR

To tar a file:

tar -cf nameOfTar.tar Folder1 Folder2

To untar a file

tar -xvf nameOfTar.tar

To untar a gzip file

tar -zxvf nameOfTar.tar.gz

Touch

A simple command that can create a file quickly

touch /var/log/somelogname.log
chmod 700 /var/log/somelogname.log
echo “this is a log file” > /var/log/somelogname.log
cat /var/log/somelogname.log


HTTPD Restart

/etc/init.d/httpd restart


Server Version

cat /etc/redhat*

CentOS release 4.5 (Final)


2)On SUSE Linux,
$cat /etc/SuSE-release


Top

Top displays a lot of system information in real time. CPU/memory/etc. It is a resource hog though.

top

Free Memory

free –m // memory


FTP

ftp server.com

use ftp -i server.com to remove confirmations. For example, downloading multiple files requires the use of mget *.*. Without logging in with -i it will force you to acknowledge the download of each file.

Reboot

shutdown -r now is reboot

Nice

Usage: nice [OPTION] [COMMAND [ARG]...]
Run COMMAND with an adjusted scheduling priority.
With no COMMAND, print the current scheduling priority. ADJUST is 10
by default. Range goes from -20 (highest priority) to 19 (lowest).

-n, --adjustment=ADJUST increment priority by ADJUST first
--help display this help and exit
--version output version information and exit

Example:
cd /; nice -n 15 /usr/bin/clamscan -r | mail -s "Server: AV Scan Results" chad@xxxxxxxxxxxx.com


Display resources

cat /proc/user_beancounters

egrep "failcnt|numiptent" /proc/user_beancounters

httpd configtest

/etc/init.d/httpd configtest

No comments: