Skip to content

List Of Linux Server Commands

List of Commands

Add New User

/usr/sbin/groupadd <groupname>
/usr/sbin/useradd <username> –g <groupname>
chown <username>.<groupname> /path/to/usernamefolder
chmod 755 /path/to/usernamefolder

Set User Password

passwd <yourusername>
<enter new password>
<enter again new password>

Check RPM Status

rpm –q <rpmname>
Eg. rpm –q imap

Extract a .tar File

tar –zxvf <filename>

Manual on a Specific Command

man <command>
Eg. man sendmail

End a Session

Ctrl + Z

./<command>

[root@kuittho /usr]# ./edquota
Specifies that the command edquota is located inside current folder /usr.

View Current Date

date

View Who’s Using Computer

who

List Name of Files in Current Directory

ls -la

Create Text File

touch <name>

View File Content

cat <filename>

Move or Rename File/Directory

mv <filename1> <filename2>

Symlink

ln –s <originalfilename> <newshortcutname>

Remove File

rm <filename>

Read Mail

mail

View Current User

who am i

Send Mail

mail <emailaddress>
subject <subject>
<message>
cc. <ccemailaddress>

To end your message, go to new line and type . and <enter>

Sort File

sort <filename>

Show User Group

groups <username>

Change User Information

chfn

List the Content of a tar File

tar -tvf <filename>

Switch to Root User

su root

Make Directory

mkdir <directoryname>

Restart Server

/sbin/shutdown –r now

Shutdown Server

/sbin/shutdown –h now

Uptime

Uptime

Show Ports Information

lsof -i

Exit from Current Shell

Ctrl + D

Start X-Window System

startx

Edit file with VI Editor

vi <filename>

Copy File

cp <filename> <targetfolder>

$bash or [user@host /directory]$

If you have no home directory on a shell, your regular login will look like:
bash$, or else, it should look like: [user@host /directory]$

Boot Linux in Single Mode

During Linux booting, press Ctrl + X to switch into Text mode.
LILO bot: linux single

Remove Whole Directory

rm –rf
** This command remove all sub-directories and contens within!

Operating System Information

uname -a

Install RPM

rpm –Uvh <rpmname>

Uninstall RPM

rpm –e <rpmname> , find rpm name using rpm –q <rpmname>

Disk Usage

du –sh /var/log /home 3.5M /var/log 500M /home du –sh *

File System Usage

df

Process Status

ps ax , process status of all processes for all users and system

Top Process

top , this command display a full screen of top processes.

System Info

procinfo

Full information about Last Boot time, Load Average, average number of jobs running, number of runnable processes, total number of processes, PID of the last process run (idem), Swap info, Memory resources, Number of disks, IRQ info, Installed modules (with the -a or -m option) and File Systems (with the -a or -m option)

Add .htpasswd

/usr/local/apache/bin/htpasswd –c <directory>/.htpasswd <login_name>
Enter password: <your_password_here>
Noted: Add –c if you are creating the .htpasswd file

| more

ls | more
ls | less

Mount CD-ROM

mount /dev/cdrom
cd /mnt/cdrom

Unmount CD-ROM

umount /dev/cdrom

SUID Root

Allows the program to run as root
chmod u+s <filename>

wget

wget –P /usr/src http://www.linux.com/filename.tar.gz

Wget Directory
wget –P <save-to-directory> -r \ ftp://<username>:<password>@host;type=<type>

<type> : a-ASCii I-Binary

Wget File
wget –P <save-to-directory> \ ftp://<username>:<password>@host/filename;type=<type>

<type> : a-ASCii I-Binary

Show Installed Perl Module Path

su <user_other_than_root>
perldoc –l Gnokii::GSM

Set Date and Time

To set the system clock
date MMDDTTTTYY

Eg. date 1203133002
sets the date to Dec 3 2002 and 1.30pm

To set the hardware clock to the current system clock
hwclock –systohc

Show Perl Module Directory

perl –le “print foreach @INC”

Yank Command in VI Editor

Marking a line

Type the letter “m” and any other letter to mark the start of line.
Eg. mt

Capture lines into the buffer

Yanks a single line (defined by current cursor position):
yy

Yanks from current cursor position to the line marked “t”
y’t

Paste yanked lines
p

Create tar File

tar options ‘Preserve attribute’ is enabled by default for root user.
tar –cf <output filename> <target file or directory>

Extract Files from a tar File

tar xf <tar file> <target file>, where target file (eg. tmp/mysql.sql) can be found by listing the content in a tar file using tar tf <tar file>

Email Lock Problem

/var/spool/mail/<username> and remove .<username>.pop

Extract Gunzip file

To extract a file compressed with gunzip, type the following:
gunzip filename_tar.gz

then if you receive no errors, type:
tar xvf filename_tar

Change the time zone at system

timeconfig

Select timezone for the system:
Example:
Asia/Kuala Lumpur
[ ] System clock uses UTC (Universal Coordinated Time)
OK

MySQL Import

mysql -u <<username>> -p<<password>> <<database_name>> <<directory_of_file.sql>>
Example:
mysql -u root -ppassword sample < /tmp/sample.sql

MySQL Export

mysqldump -u <<username>> -p -A > <<directory_of_file.sql>>
Example:
mysqldump -u root -p -A > /tmp/alldb.sql

Cron – Ignore all Stdout message of PHP

0 0 * * * /usr/bin/php /home/dbmst/web/cron/delete.php > /dev/null
Command:
> /dev/null

Cron – Ignore all Stdout and Stderr message of PHP

0 0 * * * /usr/bin/php /home/dbmst/web/cron/delete.php > /dev/null 2>&1
Command:
> /dev/null 2>&1

wc – Count the number of lines or characters

Example: Lists the number of files and directories in the directory ‘etc’
ls /etc | wc -l

Example: Lists the number of lines, words and characters in the file ‘sendmail.cf’
wc /etc/sendmail.cf

wc – Count the number of files in a directory

Example: Lists the number of files in the directory ‘etc’
ls /etc | wc -w

Example: to count the number of files in a directory and print the result in a nice message.
Here is the command (Use the ` symbol to surround commands within commands):
echo “you have `ls | wc -w` files in this directory”

cat – concatenate files

Example: Create a file named myfile and allow you to enter contents.
cat>myfile
Press Control-D to exit entry mode
WARNING: If “myfile” already existed, this command would replace the old file with the contents of the new file.

Server Release Version

cat /etc/redhat-release

CPU Model

grep “model name” /proc/cpuinfo

Ram Size

grep MemTotal /proc/meminfo

Hard Drive Size

fdisk -l

Categories: Lesson, Linux, Server, Solution, Web Hosting.

Comment Feed

4 Responses

  1. http://www.technicalguy.org – great domain name for blog like this)))

  2. http://www.technicalguy.org – cooooolest domain name)))
    ————————
    sponsored link: http://lilid.ru/

  3. http://www.technicalguy.org – great domain name for blog like this)))
    ————————
    my blog: http://zehon.ru/

  4. http://www.technicalguy.org – now in my rss reader)))
    ————————
    my blog: http://vahar.ru/



Some HTML is OK

or, reply to this post via trackback.