Vous êtes sur la page 1sur 16

BASIC COMMANDS

BASIC COMMANDS
man displays pages from system documentation. man <command> cat - View a file Ex: cat filename

ls - List contents of a directory.


Ex: ls, ls l , ls ld ls -a will list all the files including hidden files that start with . cp - Copy a file from one location to another.

Ex: cp file1 file2 : Copy file1 to file2


Ex: cp R dir1 dir2 : Copy dir1 to dir2 mv - Move or rename a file or directory. Ex: mv <source> <destination> if destination does not exist the source should be a single directory. tail - tail Look at the last 10 lines of a file. Ex: tail <filename> Ex: tail -100 <filename> head - Look at the first 10 lines of a file. (head <filename>)

more - More is a filter for paging through text one screenful


at a time.

which - Show full path of commands where given commands


reside. (which <command>) very helpful when a command seems to be working in an unexpected way.

whereis - Locate the binary and man page files for a command.
Ex: (whereis <program/command>) some commands are directly builtin in the shell, shell always executes a shell builtin before it tries to find command with the same name in your search path.

apropos - (apropos <keyword/command>) searches for the utility


using a keyword, it list the short description for all the man pages that contain the keyword somewhere in the header line. man K <command> gives the same output as apropos.

who displays a list of users currently logged in. the info given by who is uer name, terminal that each person is using, date & time of login, remote computer where the person is logged in. who am i to find out which terminal you are using or what time you logged in. finger displays the list of users that have logged in. it supplies each users login name, full name, terminal that the person is using, how recent the user has typed on the keyboard, time of login, remote system from where the user has logged in. can use finger to learn more about a individual by specifying the login name. finger <login_name> can use the finger utility to learn about a persons login name if we know the first or last name. w - displays the list of users that have logged in. it supplies each users login name, terminal that the person is using, how recent the user has typed on the keyboard, time of login, remote system from where the user has logged in, processor time each person has used during the session and on the task currently running, command currently running by each person. 1st line of w displays current time of day, how much time computer is running, number of users logged in, how busy the system is (laod averaged represents the number of waiting to run averaged over last 1,5,15 min.).

write utility is used to send a msg to another user logged in, when the other person uses write to communicate back a two-way communication is established. write destination-user-name copies text line by line from one terminal to the other, press control-D to stop communication this will display a EOF on the other users terminal. talk to carry a two-way communication with another person who has logged in on your system, or another system connected to the network. talk <uer_login> Screen splits into two parts, to end press control-c . mesg n used if a user does not want to receive msg from another user using talk or write. can allow to send msg again by entering mesg y mesg tell if someone can send you a msg, if IS Y is the respond then msg allowed, if IS N then msg not allowed.

pwd - Print or list the present working directory with full path. mkdir - Make a directory.
Ex: mkdir <directory name> : Makes a directory
mkdir put two entries in every directory we create they are single period (.) and a double period (..), represnting the directory itself and the parent directory.

rmdir - Remove a directory. The directory must be empty. You cannot


delete the working directory.
Ex: (rmdir <directory>)

rm - Delete files (Remove files).


Ex: (rm rf <directory/file>)

cd to make another directory the working directory.


cd <directory_path> without an argument cd makes your home directory the working directory.

sort - Sort a file alphabetically.


contents of file in order by lines, upto a certain limits can sort numbers.

uniq - Remove successive duplicate lines, so uniq ensures that no two lines are the same from a sorted
file.

cmp - Compare two files.

diff - Show the differences between files. Does not change either files, just displays the list of action you
need to convert one file into another. Ex: diff file1 file2 : Find differences between file1 & file2. produces a series of instructions to add, delete or change. Followed by the line that u need to add, delete or change.

echo - Display a line of text.

passwd to change password


compress - Compress data. Marks the file as a .Z file. uncompress - Expand data. gzip - zip a file to a .gz file. v option reports how much it was able to reduce the size.
It does not change the modification date associated with the file.

gunzip - unzip a gz file.

zcat allows to view .gz and .Z files, interprets the compressed data and the content as though it were
not compressed.

tar Archives files and directories.


Ex: tar -zcvf <destination> <files/directories> - Archive copy groups of files. tar zxvf <compressed file> to uncompress files are compressed with gzip to make storing and handling more efficient. These file will have the extension .tar.gz or .tgz

tar

grep - List all files with the specified expression.


(grep pattern <filename/directorypath>) enclosing string in single quotation mark will allow us to put spaces and special characters.

Man Command
Man ual command. man man This is help command, and will explains you about online manual pages. you can also use man in conjunction with any command to learn more about that command man ls - will explain about the ls command and how you can use it.

Based on the SSTND linux system manual are divided into 9 section
1. user programs 2. system calls 3. library functions 4. special files (devices) 5. file formats 6. games 7. miscellaneous 8. system administration 9. kernel internal variables and function.

Unless you specify a section, man displays the earliest occurrence in the manual of the word you specified on the command line. Suppose we have a write utility and a write system call $ man write will give man pages for write utility $ man 2 write will give man pages for system call You can restrict man utility to a group of section using the S option $ man S 1:6:7 signal

lpr command
lpr command to print a file. Several people or jobs can use a single printer. Places one or more files in the printer queue for printing. Syntax: $ lpr filename Use P option to place files in a specific printer queue. $ lpr Pprinter_name filename lpq to see what jobs are in the printer queue. lprm utility can be used to remove the job from the printer queue using the job number.

file command
File command displays about the contents of a given file, whether it is a text (Ascii) or binary file. To use it type: $ file filename. EX: $ file resume.doc resume1.doc: data file $ file cal.txt cal.txt: ascii text

wc command
wc command counts the characters, words or lines in a file depending upon the option.
wc -l filename will print total number of lines in a file. wc -w filename will print total number of words in a file. wc -c filename will print total number of characters in a file.

cal command
cal command cal command will print the calander on current month by default. If you want to print calander of august of 1965. That's eightht month of 1965. cal 8 1965 will print following results.

Clear command clear command clears the screen and puts cursor at beginning of first line. tty command tty command will display your terminal.

Vous aimerez peut-être aussi