Вы находитесь на странице: 1из 6

alias

Create an alias to display all files in the current directory. unalias cancels the alias.
Example:
$ls #Display all files and directory in the current directory (note the format).
$ls –al #Notice on the differences.
$alias ls='ls -al' #Create an alias to display all files in the current directory.
$ls #Execute the ls command alias.
$unalias ls #Un-alias the ls command.
at
Execute a command at a specified time.
Example:
$ls –al > testjob #Save ‘ls –al’ output into the testlsal file.
$echo ‘cp testjob testjob2’ > jobrun #Write a program to copy file and name it jobrun.
$chmod 700 jobrun #Give read, write, and execute access permission to owner.
$date #Check the date – assuming the time is 10:25.
$at –f jobrun 10:30 #Schedule to run the job after 5 minutes.
$ls –l testjob* #After 5 minutes, you should get the copy of your file.
cal
Display the calendar of the current month
$cal #Display the current month calendar.
$cal 2003 # Display the calendar of the year 2003
cat
Display one or more files.
Example:
$touch test #Create a file named test.
$ls –al > test #Copy the output of ‘ls –al’ command into the test file.
$cat -n test #Display the test file with numbers in ascending order in front of each line.
cd
Change the current directory.
Example:
$cd #Change the current directory to the user default home directory.
$cd /u01/app/oracle/product/9.1.3 #Change the current directory to /u01/app/oracle/product/9.1.3
chggrp
Change group of the named file or directory.
Example:
$su root #su to root.
$ls –al > test #Write ‘ls –al’ output into the test file.
$ls –l test #Display all information about the test file.
$chgrp oracle test #Change the group ownership of the test file.
$ls –l test #Display again the test file information using the long list format (-l)
chmod
Set file access permissions.
Example:
$ls –al > test #Write ‘ls –al’ output into the test file.
$ls –l test #Note on the test file access permissions.
$chmod ugo+rwx test #Give read, write, and execute access to owner, group and other users.
$ls –l test #Note on the test file access permissions.
$chmod u+rw,g+r test #Give read and write access to owner, read access to group, and nothing to group
$ls –l test #Note on the test file access permissions.
chown
Change the owner of a file or directory.
Example:
$su root #su to root.
$ls –al > test #Write ‘ls –al’ output into the test file.
$ls –l test #Note that who owns the file.
$chown oracle test #Give the ownership of test file to oracle user.
$ls –l test #Note that who owns the file.
chsh
Change the Unix shell you log into.
$chsh –l #List all of the installed shells in your machine.
$chsh –s /bin/ksh #Change the current user shell to the korn shell.
clear
Clears the display. Only the prompt is displayed.
Example:
$ls –al #Display all files’ name and directories in the current folder.
$clear #Clear the screen.
cmp
Compares files.
Example:
$ls –al > testlsal #Save ‘ls –al’ output into the testlsal file.
$ls –l > testlsl #Save ‘ls –l’ output into the testlsl file.
$cmp testlsal testlsl #compare the testlsal file with the testlsl file.
$cmp testlsal testlsal #compare the testlsal file with itself.
compress
Compress the named file. The compressed file gets .Z appended to the filename.
Example:
$ls –al > testcompress #Save ‘ls –al’ output into the testlsal file.
$ls –l testcompress #Check the file size.
$compress –v testcompress #Compress the file and display compress messages (-v).
$ls –l testcompress #Check the file size.
$more testcompress #Check the compress file.
$uncompress testcompress #Uncompress the file.
cp
The cp command allows you to copy files to new files, or copy files and directories to new directories.
-i - Ask before updating a file or directory that exists in the destination with the same name.
-r - To copy a directory including its contents to a new directory, recursive.
Example:
$ls –al > testcopy #Save ‘ls –al’ output into the testcopy file.
$mkdir copydir #Create a copy directory.
$cp -i testcopy ./copydir #Copy the testcopy file into the copydir directory.
$cp -i testcopy ./copydir #Repeat this and see the difference.
$ls –al ./copydir #Check to see your file was copied.
$mkdir copydir2 #Create another directory.
$cp -r ./copydir/* ./copydir2 #Copy all the files from the copydir directory to the copydir2 directory.
$ls –al ./copydir2 #Check to see your file(s) was/were copied.
echo
Echo argument.
Example:
$echo ‘this statement’ #Display or echo ‘this statement.’
$GLOBLVAR=’my 2nd test’ #Define a Global variable and assign a value to it.
$export GLOBALVAR #Export the value.
$echo $GLOBALVAR #Display or echo the content of your global variable.
date
List current date and time
Example:
$date #Display time on the output device.
$date > testdate #Write date on the created testdate file.
$more testdate #Display the testdate content.
$echo ‘Date is in top’ >> testdate #Append the ‘Date is in top’ message in the testdate file.
$more testdate #Display the testdate file.
df
Shows disk space available on the system (-k Use 1024 byte blocks instead of the default 512).
Example:
$df –k #Display all space available on the system.
diff
Display the differences between two text files.
Example:
$ls –al > testlsal #Save ‘ls –al’ output into the testlsal file.
$ls –l > testlsl #Save ‘ls –l’ output into the testlsl file.
$diff testlsal testlsl #compare the testlsal file with the testlsl file.
$diff testlsal testlsal #compare the testlsal file with itself.
du
Display how much disk space is being used by directories.
-a - Shows counts for all files encountered, not only directories.
-k - Use 1024 byte blocks instead of the default 512.
Example:
$du –k /u03/app/oracle #Display disk space used in the /u03/app/oracle directory by directories.
$du –ak /u03/app/oracle #Display disk space used in the /u03/app/oracle directory by files and directories.
ftp
FTP to a site (or IP address)
Example:
ftp 205.204.23.176 #Copy a file from one machine to anothers.
ftp> get myfile.txt /u03/oradata/myfile.txt
fpt> put myfile.txt /u05/oradata/myfile.txt
fpt> bye

/opt/sfw/bin/wget http://...... #copy or ftp file from one server to another using the URL address.

grep
Searchs for a string in a file.
Example:
$ps –ef|grep ora_ #Show only those process that start with ora_
$ls –al |grep oracle #Display all the lines that has oracle word in it.
gzip
Compress a file.
Example:
$ls –al > testcompress #Save ‘ls –al’ output into the testlsal file.
$ls –l testcompress #Check the file size.
$gzip testcompress #Compress the testcompressfile.
$ls –l testcompress #Check the file size.
$more testcompress #Check the compress file.
$gunzip testcompress #Uncompress the file.
jobs
Display active processes.
Example:
$jobs #Show the list active jobs.
ls
Show files in the current directory ls, ls -l (Displays the file details), ls -a (Displays hidden files), (hidden files in
UNIX begin with a dot (.)), the current directory and parent directory entries (. and .. respectively).
Example:
$ls #Show all files and directories.
$ls –l #Show all files and directories in long format.
$ls –al #Display all files and directories plus the hidden files.
make
Compile a source code.
Example:
$make your_source_program #Compile your source program.
man
Read the help man command
Example:
$man cp #Help information for ‘cp’ command.
mkdir
Create a directory.
-i parameter will make the system prompt you before deleting a file or directory.
Example:
$cd /u03/oradata #Change the directory to the /u03/oradata directory.
$mkdir –i userdata #Make a directory called userdata and prompt if exist.
$ls –al #Check that the directory was created.
$rmdir userdata #Remove the directory.
more
View a file.
Example:
$more testcopy $Display a file and pause. Enter space key to go to next page.
mv
Rename or move a file.
Example:
$ls –al > testmove #Save ‘ls –al’ output into the testmove file.
$mkdir movedir #Create the movedir directory.
$mv -i testmove ./movedir #Move the testmove file into the movedir directory. Prompt if it is duplicate.
$ls –al ./movedir #Check to see your file was moved.
passwd
Change password.
Example:
$passwd #Change the current password to the new password.
ping
Ping an IP address.
Example:
$ping mymachine #Ping using dsn name.
$ping 127.0.0.1 #Ping using ip address.
ps
Display processes status.
Example:
$ps –ef|grep ora_ #Display all the processes that start with ora_
pwd
What is the current directory.
Example:
$pwd #Display the current directory name.
rm
Delete/remove a file.
Example:
$ls –al > testremove #Save ‘ls –al’ output into the testremove file.
$ls –l testremove #Check the testremove file exists.
$rm testremove #Remove the file.
$ls –l testremove #Check again to see the testremove file exists.
rmdir
Remove a directory.
Example:
$cd /u03 #Change directory to /u03
$mkdir myfolder #Create the myfolder directory in the current folder.
$cd myfolder #Change the current folder to the new created folder.
$df –k > myfirstfile #Create a file.
$cd .. #Go back to /u03
$rmdir myfolder #Notice that when you remove the directory, it must be empty.
$rmdir –r myfolder #Use r parameter that to remove files or directories recursively.
tail
Show last lines of a file.
Example:
$ls –al > testtail #Save ‘ls –al’ output into a file named ‘testtail.
$ls –al >> testtail #Append the output one more time.
$ls –al >> testtail #Append the output again.
.. do the above step number of times. May be 3 more times.
$cat –n testtail #Get a feel that how big your file is now (-n option will print the line number).
$tail -5 testtail #Print only the last 5 lines of the testtail file.
tar
Archive files.
Example:
$ls –al > test_tar #Save ‘ls –al’ output into a file named ‘test_tar.
$ls –al >> test_tar #Append the output one more time.
$ls –al >> test_tar #Append the output again.
.. do the above step number of times. May be 3 more times.
$ls –l test_tar #Check the size.
$tar –cvf test_tar.tar test_tar #Create a tar file and name it test_tar.tar.
$ls –l test_tar* #Check to see that the tar file was created (-c option will create tar file).
$rm test_tar #Remove the test_tar file.
$tar –xvf test_tar.tar #Un-tar the test_tar.tar file.
$ls –l test_tar #Notice that the file is back.
telnet
Connect to a server by hostname (using dns) or IP address.
Example:
$telnet 155.55.143.12 #Telnet to a server using IP address.
$telnet hostname #Telnet to a server using dns hostname.
whereis
Locate the binary, source, and manual page files.
Examples;
$ls –al > findme #Save ‘ls –al’ output into a file named ‘findme.’
$cd / #Change the directory to root.
$whereis findme #Find the created file.
who / Who am i
Who are loged in?
Example:
$who #Display all users that are loged in.
$w #Display all users that are loged in and what they doing.
$whoami #Display who am I.
$id #Display who am I.
zip
Compress to zip for IBM files.
Example:
$ls –al > test_zip #Save ‘ls –al’ output into a file named ‘test_zip’.
$zip test_zip #Compress to zip for IBM files.

Вам также может понравиться