Академический Документы
Профессиональный Документы
Культура Документы
16/11/2009
Operators
= (assign permission)
+ (add permission)
- (revoke permission)
File Manipulation
Viewing File
cat - read one or more files and print them on the standard output
• cat filename Print the mentioned file in the standard output.
• cat –v filename Read the file named filename and prints all the lines including
special characters
• cat –n filename Read the files with all the output lines numbered.
• cat –s filename Read the files but squeeze multiple blank lines to single line.
• cat file1 file2 file3 > Filename Creates filename combining the contents of file1, file2
and file3.
head – displays the starting part of the file. It will display till the specified byte or line
number.
• head filename Prints the first 10 lines of the files to standard output
• head –c byte_count filename Prints the specified byte_count of filename to
standard output
• head –n line_num filename Prints line_num lines of filename to standard output
tail – prints three last 10 lines of the files mentioned. If more than one fie is mentioned
then file header is also included for each file.
• tail filename Displays the last 10 line of the file
• tail –n line_count filename Displays the last line_count from the file.
• tail –c byte_val filename Displays the last byte_val from the last part of the file.
more – displays one page at a time for files with more than a page.
• more filename Scroll through one page at a time though the file.
less – display the content of the file with one page at a time. Allow the user to move one
line/page up or down at a time. Powerful command compared to more command.
• less filename Allows the user to move forward or backward through the file.
pwd – displays the present working directory.
• pwd Print the full pathname of the current working directory
File Comparison and Difference
cmp – check whether 2 given files contents are same/similar. Used to get the char and the
line number that is varied between the files.
• cmp filename1 filename2 Check whether the filename1 and filename 2 are similar
or else will print the byte and line number which is not similar.
• cmp –s filename1 filename2 Check whether the files are similar else return with exit
codes (0- file are identical, 1 – files are different & 2 – files are not accessible) and
will display nothing.
diff – used to find the difference between two files. Can be used to compare files from
directory with files from another directory.
• diff filename1 filename2 compares filename1 and filename2 and prints the output
with < for contents in filename1 and not in filename2 and prints output with > for
contents in filename2 and not in filename1.
• diff dirname1 dirname2 Compares files in each directory and if similar file name
exists exists, then it will compare the contents inside the file
du – check the space usage for all the files in the directory.
• du Prints the space usage of the files
• du filename Prints the space usage of the filename
• du –a Prints the space usage of all the files.
• du –c Prints the space usage of the files and grand total.
• du –h Prints the space usage of the files in human readable format.
• du –k Prints the space usage of the files in kilobytes.
• du –m Prints the space usage of the files in megabytes.
• du –s Prints the total space usage alone.
wc – gives the byte/word/line count of the given file depending upon the options
specified.
• wc –c filename Prints the byte count in filename
• wc -m filename Prints the character count in the filename
• wc –l filename Prints the newline count in the filename
sum – prints the checksum and the blocks for file.
• sum filename Displays the checksum and block counts of the file.
• sum * Displays the checksum and block counts of the file in the current directory.
uptime – prints details about the current time, number of users, system load, how long the
system is running and system load for the past 1, 5 and 15 minute.
top – provide information about the processes using the cpu resource.
• top Displays information about the tasks, memory status and cpu usage
• top –d delay_time Displays the details in a interval of delay_time
• top –n no_of_iteration Displays the details for mentioned number of iteration
alone.
stat – Gives the details of the i-node of the file which is the output of the stat system call.
• stat filename Displays the details about the file such as Inode, size, blocks and
access rights
• stat –f filename Displays the details about the file system instead of the file
Process
bg - send a job mentioned by its job ID to execute in background
• bd <process_id> Sends the process with process_id to execute in background.
fg – brings the command executed in background to foreground.
• fg job_id Brings the process with job_id to foreground and executes it.
usleep – sleep for some specified number of microseconds.
• usleep time_interval The system suspends processing for the specified number of
microseconds. The default value is 1.
sleep – keep the process in waiting state for the specified amount of time before
executing the next command.
• sleep time_interval Sleeps for specified amount of time in seconds
ps – Displays information about the current active process
• ps –ef to display information about all the process on the system.
• ps axjf Display information about the process tree
• ps axms Display information about all the threads.
nice - Sets the priority for a process between -20 (highest priority) and 19 (lowest priority)
with default being 10. without options its displays the current priority.
• nice –n value command<arguments> Executes the commands with lowering the
priority by the value. Administrative user can increase the priority of the process or
commands.
kill –kills the specified processes, sends the specified processes the specified signal (given
as a number or name)
• kill 0 Kill all the process in the current process group are signaled
• kill 1 All the process with process ID larger than 1 are signaled
• kill PID Kill he process with whose pid is equal to PID
• kill -9 PID Used to terminate process that normal kill command fails to signal.
Job scheduling
crontab – schedule a job to execute at a specified time or keep on executing the job after
a specified interval.
• crontab filename Create/Replace your crontab file
• crontab –l username Lists the users crontab file for username
• crontab –e username Edit the users crontab file for username
• crontab –r username Remove the users crontab file for username
File transfer
ftp – its a file transfer protocol. Used to transfer file from and to a remote network.
• ftp remote_hostname Connect to remote machine for transferring files after
successful login.
• ftp –n remote_hostname Enable file transfer which restrain from using auto_login,
check for details in .netrc files for account of remote machine.
sftp – interactive program that securely transfers files. It perform all operations over
encrypted ssh transport.
• sftp dest_hostname Connect to the destination host and opens an interactive
program to carry out the specified operation.
Accessing and working on remote host
rexec – connects the local host to remote host and execute the command at the remote
host.
• rexec remote_host –n command Connects to the remote_host by getting the user
name and password in command line.
• rexec –l username –p password remote_host command Connects to the remote host
after authenticating with the mentioned username and password.
rlogin – connects your terminal on the local host to remote host system.
• rlogin hostname –l user_name Login to remote host with a different user_name.
rsh - connects to the specified remote host and executes the specified command
authorizing the user with the login name and password. Copies the standard input to
remote terminal and displays it to the standard output.
• rsh hostname Login to the remote host.
• rsh –l username Login with username instead of the default name of user executing
the command
ssh – securely log to a remote system and execute the specified command on the
remotely connected system.
• ssh dest_name –p port_number Connects to dest_name host securely using the
specified port number.
telnet – user interface that communicates with remote system using telnet protocol.
• telnet hostname Connects to the remote host.
• telnet –K hostname Connects to remote host but prevents automatic login.
ping - check for the online status of the remote host using echo request. A response
confirms that the host is active and operational.
• ping destination Sends ICMP packet request to destination to check for the online
status. Stops when it receives an interrupt.
• ping –c count destination Stops after sending count number of ICMP request to
destination