Home » , , » Linux system administrations commands

Linux system administrations commands

Written By 1 on Saturday, February 5, 2011 | 1:22 PM

In our last few assignments you learnt system administration related task which a normal user can perform. In this assignment I will direct you some handy task for root user. To accomplish this assignment login form root account.
linux commands

Know how much space is consumed


#du
This command will show the usages of disk by files and folder. Output of this command show in bytes. To show it in KB use –h switch.

#du -h [file name]
To know that how much space is consumed by any specific file. For example

#du –h test
12 Kb test
Command is showing that size of test file is 12 kb.
linux commands

Know how much space is available


#df [partition]
df command is used to know the available space on any given partitions. For example to know available space on / partition use this command

#df /

How to find any files


#find [where to find] – name [what to find]
find command is used to find any object in linux. For searching object you can also use locate command but locate command is based on mlocate database. For example to find vinita directory on entire linux use

#find / -name vinita
linux commands
Or to find only in /home partition use

#find /home –name vinita

How to abort any command

Some time you need to abort any command sequences. For example output of ping will not stop by default. Or some type you miss typed any command and press entered now command prompt is hanged in such a situation use CTRL+C key combination to abort the command in mid.

How to locate any command path


#which [command]
shows the full path of (shell) commands.Which command will tell you that which command are you using. By default a user use command form the path set in his profile. Its very handy tool specially in shell scripting.
linux commands

#whereis [command]
locate the binary, source, and manual page files for a command

How to use history and clear it

history utility keeps a record of the most recent commands you have executed. The commands are numbered starting at 1, and a limit exists to the number of commands remembered—the default is 500. To see the set of your most recent commands, type history on the command line and press ENTER. A list of your most recent commands is then displayed, preceded by a number.

#history
#history –c
Use –c switch with history command to clear the history.

Check running process and terminate


#ps
The ps ( process status) command is used to provide information about the currently running processes, including their process identification numbers (PIDs). A process, also referred to as a task, is an running instance of a program. Every process is assigned a unique PID by the system
linux commands

#ps –ef
The -e option generates a list of information about every process currently running. The -f option generates a listing that contains fewer items of information for each process than the -l option. Among the columns displayed by ps -ef, UID contains the username of the account that owns the process (which is usually the same user that started the process) and STIME displays the time the process started, or the starting date if it started more than 24 hours ago.

#kill [ps number]
The kill command is used on Linux to terminate processes without having to log out or reboot the computer. Thus, it is particularly important to the stability of such systems. Each process is automatically assigned a unique process identification number (PID) when it is created for use by the system to reference the process.
The only argument that is required is a PID, and as many PIDs as desired can be used in a single command. Typically no signal or option is used. Thus, if it is desired to terminate a process with a PID of 485, the following will usually be sufficient:

kill 485

#pstree
pstree command displays the processes on the system in the form of a tree diagram. It differs from the much more commonly used (and more complex) ps program in a number of respects, including that the latter shows the processes in a list rather than a tree diagram but provides more detailed information about them.

how check user set environment


#env
env command will display the environment set for user. A brief description about this output is

EDITOR Name of editor used.
HOME The directory that you are first logged into
SHELL The program you run as your command-line interpreter.
TERM The type of terminal emulation used
PATH Listing of directories searched when logging on
MAIL Location of where the mail is stored
MANPATH Location of your Manuals.
LOGNAME The login name
TZ Time zone of computer

how to check CPU run time status


#top
When you need to see the running processes on your Linux in real time, you have top as your tool for that. top also displays other info besides the running processes, like free memory both physical and swap. use q to quit from the output of top commands.

how to set alias for commands


#alias san=clear
alias command is used to set alias with any command. Mostly alias is used in shell scripting. In our example we set an alias for clear command. Now whenever you need to clear the screen type san instead of clear command. This will work till only you are logged in if want to set alias permanently then do editing in user profile files.

#uname –a
uname command is used to gather the system information’s. you can use several switches with commands. Few of them are.
linux commands

-a, --all
print all information, in the following order:
-s, --kernel-name
print the kernel name
-n, --nodename
print the network node hostname
-r, --kernel-release
print the kernel release
-v, --kernel-version
print the kernel version
-m, --machine
print the machine hardware name
-p, --processor
print the processor type
-i, --hardware-platform
print the hardware platform
-o, --operating-system
print the operating system
--help
display this help and exit
--version
output version information and exit

how to send message to all logged in user


#wall
wall sends a message to everybody logged in . The message can be given as an argument to wall, or it can be sent to wall's standard input. When using the standard input from a terminal, the message should be terminated with the EOF key (usually Control-D). The length of the message is limited to 20 lines.

To shutdown the system


#halt –p
#init 0

To reboot system


#reboot –f
#init 6
#reboot

0 Comment:

Post a Comment