$ cal - Calendar 2000
$ who - Who is logged on
$ finger - Details of logged on users
$ write - To send messages to users
$ Ctrl+D - End of file
$ mesg n - To deny talking
$ mesg - To know the status
$ Man - Help command
$ cat - Display multiple files.
$ Date - Displays the system date.
$ cd - Change directories.
$ chmod - Change security mode of a file or directory.
$ cp - copy files from one directory to another.
$ mv - Move or rename files.
$ cut - Select and extract columns or fields from a file.
$ echo - Display the specified Arguments on the output device.
$ find - Locate a file which meet the search criteria.
$ grep - Select lines or rows that match a specified pattern.
$ kill - End a process.
$ ln - Creates link directories between files,thereby allowing more than one name for a file.
$ lp - Print a file.
$ ls - lists a directory’s contents, including its files and subdirectories
$ mkdir - Make a new directory.
$ passwd - Change your Unix password.
$ pwd - Display your current path.
$ rm - Remove a file
$ rmdir - Remove a directory
$ sh - Execute a shell script.
$ sort - Sort and merge multiple files.
$ trap - Executes a command when a specified signal is received from the operating system.
$ Type cd and press enter to make sure you are in your home directory.
$ mkdir to make a new directory
$ ls to see the contents in your directory.
$ ll to see the contents in your directory.
$ cat to create a new file.
$ ctrl + z to save the file.
Basic commands
1. Log name - Displays the current logged user name
2. $Pwd --Displays current working directory
3 $Clear --For clearing the screen
4. $Exit – to logout from current user
5. $Date – Displays system date and time
Ex: Sat mar 4 04:40:10 IST 2005
6. $Who am I – Displays current user name, terminal number, date and time at which used logged into the system
Tec no ty01 mar 4 09:30
7. $Who –To displays the information about all the users who have logged into the system
Currently. I.e., each user login name, terminal number, date and time when the user logged in
Tecno1 tty01 mar 4 09:30
Tecno2 tty05 mar 4 10:10
Tecno3 tty06 mar 4 10:15
i.e. Tecno1 – log name
Tty01 - terminal name
Mar 4 - date
09:30 -time
8. $Finger – Displays complete information about all the users who are logged in
9. $Cal – Displays previous month, current month and next month calendar
10. $cal year – it displays the given year calendar
Eg: $cal 2005 --it takes year from 1 t0 9999
11. $Cal month year – it displays the given month calendar only
12. #Init --to change system run levels
i. #Init 0 -to shutdown the system
ii. #Init 1 – to bring the system to single user mode
iii. #Init 2 –to bring the system to multi user mode with no resource shared.
iv. #Init 3 –to bring the system multi user mode with resource shared
v. #Init 6 – halt and reboot the system to the default run level.
13. $banner “Bayon” – it prints a message in large letters
Commands Related To File Creation
There are two commands to create files 1. Touch and cat
1. Touch filename - it creates zero byte file size
Eg: $ touch samplefilename
The size of sample file is zero bytes. Touch does not allow you store anything in a file. It is used for creating several empty files quickly.
Eg: $ touch file1 file2 file3 file4 file5
2.cat command
Syntax
i. $Cat >filename
E.g.: $cat >samplefilename
----------------
----------------
----------------
Ctrl+d (to close a file)
ii. $Cat >> samplefilename --to append data to the file
----------------
----------------
----------------
Ctrl+d
iii. $Cat file1 file2 file3 >file4
This would create file4 which contains contents of file1 followed by file2 and
Followed by that of file3. i.e., it concatenates file1, file2 and file3 contents and
Redirects to file4. If file4 already contains something it would be over written.
3. $ Cat <filename or $cat filename --to open a file
E.g: $cat sample --it displays sample file contents
E.g: $cat file1 file2 file3
-It displays file1 contents followed by file2 then followed by file3.
Commands for Removing files
4. Rm command -to removes the given file
Syntax: $rm filename
$Rm sample -it removes sample file
$Rm –I filename -it asks confirmation before deleting the file.
$Rm – sample
Remove sample? y –it removes
N – it won’t remove
$Rm file1 file2 file3 -it removes three files
$Rm * -it removes all files in current directory
Commands for Creating directories
5. Mkdir command -to make directory
Syntax: $mkdir directory name
e.g: mkdir techno
Creating multiple directories
$Mkdir dir1 dir2 dir3 …darn
Commands For Changing directories
Syntax: $cd directory name
$Cd oracleappsguy
$Pwd
/usr/temp/oracleappsguy
$cd .. –to change into parent directory
$cd\ -to change to root directory
Commands For Removing directories
1. $rmdir directory name -to delete a directory but directory should be empty
2. $rm –r directory name – it removes all files and sub directories, sub directory files
Including directory.
Directories:
File and directory paths in UNIX use the forward slash "/" to separate directory Names in a path.
Examples: / "root" directory
/usr directory usr (sub-directory of / "root" directory)
/usr/STRIM100 STRIM100 is a subdirectory of /usr
Moving around the file system:
pwd Show the "present working directory", or current directory.
cd Change current directory to your HOME directory.
cd - go to previous directory(like undo).
cd /usr/STRIM100 Change current directory to /usr/STRIM100.
cd INIT Change current directory to INIT which is a sub-directory of the current
directory.
cd .. Change current directory to the parent directory of the current directory.
cd $STRMWORK Change current directory to the directory defined by the
environment variable 'STRMWORK'.
cd ~bob Change the current directory to the user bob's home directory (if you
have permission).
ls list a directory
ls -l list a directory in long ( detailed ) format
Example:
$ ls -l
drwxr-xr-x 4 cliff user 1024 Jun 18 09:40 WAITRON_EARNINGS
-rw-r--r-- 1 cliff user 767392 Jun 6 14:28 scanlib.tar.gz
| | | | | owner group size date time name
| | | | number of links to file or directory contents
| | | permissions for world
| | permissions for members of group
| permissions for owner of file: r = read, w = write, x = execute -=no permission
type of file: - = normal file, d=directory, l = symbolic link, and others...
drwxr-xr-x first 1 letter is indicate directiry or file, d is directory,- is file.
Next 9 letters are indicate owner(3), group(3), user(3) rights resp.
ls -a List the current directory including hidden files. Hidden files start with "."
ls -ld * List all the file and directory names in the current directory using long format.
Without the "d" option, ls would list the contents of any sub-directory of the
current. With the "d" option, ls just lists them like regular files.
ls t* list all directories or files which start with ‘t’
Changing file permissions and attributes:
chmod 755 file Changes the permissions of file to be rwx for the owner, and rx for
the group and the world.(7 = rwx = 111 binary. 5 = r-x = 101 binary)
chgrp user file Makes file belong to the group user.
chown cliff file Makes cliff the owner of file.
chown -R cliff dir Makes cliff the owner of dir and everything in its directory tree.
You must be the owner of the file/directory or be root before you can do any of these things.
Moving, renaming, and copying files:
cp file1 file2 copy a file(if file2 not exists it will create a new file)
mv file1 newname move or rename a file(rename)
mv file1 /AAA/bbb move file1 into sub-directory AAA in your home directory.
rm file1 [file2 ...] remove or delete a file
rmdir dir1 [dir2...] remove an empty directory
rm -r dir1 [dir2...] recursively remove a directory and its contents BE CAREFUL!
mkdir dir1 [dir2...] create directories
mkdir -p dirpath create the directory dirpath, including all implied directories in the
path.
cmp [options] file1 file2 compare two files and list where differences occur
(text or binary files)
diff [options] file1 file2 compare the two files and display the differences
(text files only)
chsh (passwd -e/-s) username login_shell change the user's login shell
(often only by the superuser)
date [options] report the current date and time
emacs [options] file full-screen editor
file [options] file classify the file type
ftp [options] host transfer file(s) using file transfer protocol
lpr [options] file or lp [options] file print to defined printer
passwd [options] set or change your password
wc file count number of lines/words/characters in file
who list users currently logged in
Viewing and editing files:
cat filename Dump a file to the screen in ascii.
more filename Progressively dump a file to the screen: ENTER = one line down
SPACEBAR = page down q=quit
less filename Like more, but you can use Page-Up too. Not on all systems.
vi filename Edit a file using the vi editor. All UNIX systems will have vi in some form.
emacs filename Edit a file using the emacs editor. Not all systems will have emacs.
head filename Show the first few lines of a file.
head -n filename Show the first n lines of a file.
tail filename Show the last few lines of a file.
tail -n filename Show the last n lines of a file.
Shells
The behavior of the command line interface will differ slightly depending on the shell program that is being used. Depending on the shell used, some extra behaviors can be quite nifty. You can find out what shell you are using by the command:
echo $SHELL
Of course you can create a file with a list of shell commands and execute it like a program to perform a task. This is called a shell script. This is in fact the primary purpose of most shells, not the interactive command line behavior.
Environment variables:
You can teach your shell to remember things for later using environment variables.
For example under the bash shell:
Export CASROOT=/usr/local/CAS3.0 Defines the variable CASROOT with the value
Export LD_LIBRARY_PATH=$CASROOT/Linux/lib Defines the variable
LD_LIBRARY_PATH with the value
Of CASROOT with /Linux/lib
ppended, or /usr/local/CAS3.0/Linux/lib
By prefixing $ to the variable name, you can evaluate it in any command:
cd $CASROOT Changes your present working directory to the value of CASROOT
echo $CASROOT Prints out the value of CASROOT, or /usr/local/CAS3.0
printenv CASROOT Does the same thing in bash and some other shells.
Interactive History:
A feature of bash and tcsh (and sometimes others) you can use the up-arrow keys to access your previous commands, edit them, and re-execute them.
Filename Completion:
A feature of bash and tcsh (and possibly others) you can use the TAB key to complete a partially typed filename. For example if you have a file called constantine-monks-and-willy-wonka.txt in your directory and want to edit it you can type 'vi const', hit the TAB key, and the shell will fill in the rest of the name for you (provided the completion is unique).
Bash is the way cool shell:
Redirection:
grep string filename > newfile Redirects the output of the above grep
command to a file 'newfile'.
grep string filename >> existfile Appends the output of the grep command
to the end of 'existfile'.
The redirection directives, > and >> can be used on the output of most commands to direct their output to a file.
Pipes:
The pipe symbol "|" is used to direct the output of one command to the input of another.
For example:
ls -l | more This commands takes the output of the long format directory list command
"ls -l" and pipes it through the more command (also known as a filter).
In this case a very long list of files can be viewed a page at a time.
du -sc * | sort -n | tail
The command "du -sc" lists the sizes of all files and directories in the current working directory. That is piped through "sort -n" which orders the output from smallest to largest size. Finally, that output is piped through "tail" which displays only the last few (which just happen to be the largest) results.
Command Substitution:
You can use the output of one command as an input to another command in another way called command substitution. Command substitution is invoked when by enclosing the substituted command in backwards single quotes.
For example:
cat `find . -name aaa.txt`
which will cat ( dump to the screen ) all the files named aaa.txt that exist in the current
directory or in any subdirectory tree.
Searching for strings in files: The grep command
grep string filename prints all the lines in a file that contain the string
Searching for files : The find command
find search_path -name filename
find . -name aaa.txt Finds all the files named aaa.txt in the current directory or
any subdirectory tree.
find / -name vimrc Find all the files named 'vimrc' anywhere on the system.
find /usr/local/games -name "*xpilot*"
Find all files whose names contain the string 'xpilot' which exist within the '/usr/local/games' directory tree.
Reading and writing tapes, backups, and archives: The tar command
The tar command stands for "tape archive". It is the "standard" way to read and write archives (collections of files and whole directory trees).
Often you will find archives of stuff with names like stuff.tar, or stuff.tar.gz. This is stuff in a tar archive, and stuff in a tar archive which has been compressed using the gzip compression program respectivly.
Chances are that if someone gives you a tape written on a UNIX system, it will be in tar format,and you will use tar (and your tape drive) to read it.
Likewise, if you want to write a tape to give to someone else, you should probably use tar as well.
Tar examples:
tar xv Extracts (x) files from the default tape drive while listing (v = verbose)
the file names to the screen.
tar tv Lists the files from the default tape device without extracting them.
tar cv file1 file2 Write files 'file1' and 'file2' to the default tape device.
tar cvf archive.tar file1 [file2...] Create a tar archive as a file "archive.tar" containing
file1, file2...etc.
tar xvf archive.tar extract from the archive file
tar cvfz archive.tar.gz dname Create a gzip compressed tar archive containing
everything in the directory 'dname'. This does not
work with all versions of tar.
tar xvfz archive.tar.gz Extract a gzip compressed tar archive. Does not work with all
versions of tar.
tar cvfI archive.tar.bz2 dname Create a bz2 compressed tar archive. Does not work
with all versions of tar.
File compression: compress, gzip, and bzip2
The standard UNIX compression commands are compress and uncompress. Compressed files have a suffix .Z added to their name.
For example:
compress part.igs Creates a compressed file part.igs.Z
uncompress part.igs Uncompresseis part.igs from the compressed file part.igs.Z.
Note the .Z is not required.
Another common compression utility is gzip (and gunzip). These are the GNU compress and uncompress utilities. gzip usually gives better compression than standard ompress, but may not be installed on all systems. The suffix for gzipped files is .gz
gzip part.igs Creates a compressed file part.igs.gz
gunzip part.igs Extracts the original file from part.igs.gz
The bzip2 utility has (in general) even better compression than gzip, but at the cost of longer times to compress and uncompress the files. It is not as common a utility as gzip, but is becoming more generally available.
bzip2 part.igs Create a compressed Iges file part.igs.bz2
bunzip2 part.igs.bz2 Uncompress the compressed iges file.
Looking for help: The man and apropos commands
Most of the commands have a manual page which give sometimes useful, often more or less detailed, sometimes cryptic and unfathomable discriptions of their usage. Some say they are called man pages because they are only for real men.
Example:
man ls Shows the manual page for the ls command You can search through the man
pages using apropos
Example:
apropos build Shows a list of all the man pages whose discriptions contain the word
"build"
Do a man apropos for detailed help on apropos.
Plеase let me know іf үou're loօking for a writer fߋr yoսr blog.
ReplyDeleteϒoս have ѕome rеally ցreat articles and I bеlieve I wօuld be a good asset.
If you ever want to take sοmе of tҺe load off, I'd reallƴ lіke
to write some material ffor yoսr blog in edchange fоr a link bqck to mine.
Ρlease shoot me an email if intеrested. Thank yoս!
Alѕo visit my homepaǥe ... fopds alkaline ()
Do you mind if I quote a few of your articles as long as I provide credit and
ReplyDeletesources back to your webpage? My blog site is
in the very same area of interest as yours and my visitors would
really benefit from some of the information you present here.
Please let me know if this alright with you. Thanks a lot!
Wonderful post however , I was wondering if you could write a
ReplyDeletelitte more on this subject? I'd be very thankful if you could elaborate a little bit more.
Thank you!
Depending acessível my spiritual mood of the day.
ReplyDeleteSimply desire to say your article is as amazing. The clarity in your
ReplyDeletepost is simply excellent and i can assume you're an expert on this subject.
Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post.
Thanks a million and please continue the gratifying work.
Awesome post .
ReplyDelete