Basic Command Linux System Administrator / Ops Should Know

In Linux, Some of the Command looks easy, but we have to master it , its will help you a lot.

This is all the thing i learn and i gonna share to you guys, hope this helps all of you.

Command to show you date and time

date

Command to show you the Calendar

cal will showing you current year and current month calendar, if you want to show specific year or specific year and month can be done by this command also.

cal

cal 1992

cal 07 1992 /cal july 1992

Command to bring out a Calculator 

bc

Key on Keyboard That help you on Linux

CTRL+C stop any process that current running on screen.

CTRL+D Is End of the file like EOF or it can be a substitution of exit 

Tab button on your keyboard can help you space on a standard range, and its also can help you to complete unfinished command 
ie: reb and press tab it will finished it with reboot.

Command to show all the command Manual Book

man
ie: man shutdown

Command that help you write the data on ram or virtual memory to HDD.

Normally we will do this before we reboot of we shutdown the Linux Machines.

sync

Command to shutdown your Machines

-H, –halt
Halt the machine.

-P, –poweroff
Power-off the machine (the default).

-r, –reboot
Reboot the machine.

-h
Equivalent to –poweroff, unless –halt is specified.

-k
Do not halt, power-off, reboot, just write wall message.

–no-wall
Do not send wall message before halt, power-off, reboot.

-c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not “+0”
or “now”.

You can also scheduled the shutdown by specific time. it will show this message on the screen.

shutdown -h 10 'This machines will shutdown in 10 minutes.'
init 0 << it will directly shutdown now
shutdown -h now << it will directly shutdown now

Command to Restart Machines

shutdown -r now
reboot

Linux Run Level Explain

Normally we are using 3 by default, can be changes in /etc/inittab

Command to Changes Group of the File 

chgrp
chgrp linuxscriptshub /var/www/html << html file will become Group linuxscriptshub

Command to Changes Owner of the File

chown
chown linuxscriptshub /var/www/html << html file will belongs to use linuxscriptshub

but actually chown can changes group and owner together.

chown linuxscriptshub:linuxscriptshub /var/www/html << it will changes group and owner at the sametime

Command to Changes Permission of the File

chmod

R=4
W=2
X=1

chmod 644 /var/www/html = -rw-r--r-- 
owners permission are read and write, group permission are read only, and others will be read only.

Command to check Kernel version and Bits.

uname -r

Command to Changes Directory

cd
cd /var/www/html/ << you will be in /var/www/html/ now. Command to Check which Directory you are in.

pwd

Command to copy file

cp 
cp linuxscriptshub johnsonhub
it will copy linuxscritpshub and create a new file with old content and name it johnsonhub.

Command to remove a folder and file

Usage: rm [OPTION]... FILE...
Remove (unlink) the FILE(s).

-f, --force ignore nonexistent files and arguments, never prompt
-i prompt before every removal
-I prompt once before removing more than three files, or
when removing recursively; less intrusive than -i,
while still giving protection against most mistakes
--interactive[=WHEN] prompt according to WHEN: never, once (-I), or
always (-i); without WHEN, prompt always
--one-file-system when removing a hierarchy recursively, skip any
directory that is on a file system different from
that of the corresponding command line argument
--no-preserve-root do not treat '/' specially
--preserve-root do not remove '/' (default)
-r, -R, --recursive remove directories and their contents recursively
-d, --dir remove empty directories
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit

By default, rm does not remove directories. Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.

To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
 rm -- -foo

rm ./-foo

dont ever run below command: its will delete the whole root directory.
rm -rf /*

Command to mv a file or rename a file

mv linuxscripteshub /var/www/linuxscriptshub

moving linuxscriptshub to directory /var/www/

mv linuxscriptshub windows

renaming linuxscriptshub to windows

Command to show file content without entering it.

cat
cat /var/www/html/index.html

or you can use it to clean up a file.

cat > /var/www/html/index.html

Command to locate where the file in

assume you want to find index.html but you dont know where is it.

yum install mlocate
updatedb << wait for a while in the first time
locate index.html << it will show you all the path thats index.html in.

Share this to your friends who want to learn linux.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *