GotoKnow
  • เข้าระบบ
  • สมัครสมาชิก
  • แผงจัดการ
  • ออกจากระบบ
GotoKnow

Web Unix & Linux command Line

command Line

http://www.emba.uvm.edu/CF/basic.html
http://www.emba.uvm.edu/CF/adv2.html
http://www.math.utah.edu/lab/unix/unix-commands.html

http://wks.uts.ohio-state.edu/unix_course/intro-137.html

http://www.thaibsd.com/index.php?cat=6
http://viriya.sru.ac.th/FreeBSD/install_49_draft.pdf



Basic Unix Commands

More information on almost any of the commands that follow can be found in the on-line manual pages. Type "man command-name" at the command line to look at the manual page for the command "command-name".


Files
  • Display files in a directory :ls
  • Copying files : cp
  • Delete file(s) : rm
  • What kind of file is this ? : file
  • Whats different with these two files ? diff, cmp
  • View a file in PostScript (.ps file): ghostview
  • Change permission : chmod
  • Moving files : mv
Environment
  • Keep getting "Can"t open display: :0" :setenv
  • Display current environment variables: env


Networking
  • Write message to persons screen: write
  • Graphically display new mail xbiff
  • Information on a person : finger
  • Information on people logged-on rwho
  • Printing a file : lpr
  • Check the print queue : lpq
  • Cancel print jobs :lprm
  • Information on Servers : rupall
Directories
  • Where am I now ?? : pwd
  • Moving around : cd , ln
  • Create a directory : mkdir
  • Delete a directory : rmdir
  • Change permissions to a directory : chmod
  • How much disk space do I have left ? quota -v
Processes
  • What program is running now? jobs, ps

Passwords

c++ {filename}A compiler for the C++ programming language. Command line parameters are similar to the "cc" compiler"s. A typical invocation might be "c++ -g file.cpp -o executablename -llib".


cat {filename}Prints out ( to the screen ) the contents of the named file. Can also be used to concatenate files. Say you want file1 and file2 to be all together in one file named file3. If file1 is first, then "cat file1 file2 > file3" will produce the correct file3.


cc A compiler for the "C" programming language. "cc" is ANSI compatible on the SGI, IBM, and newer Sun machines. You might try also try "gcc", GNU CC, which is also available on the SGI, SUN, and IBM machines. A typical invocation might be "cc -g file.c -o executablename -llib".


cd {dirname}Change current directory. Without a "dirname", it will return you to your home directory. Otherwise, it takes you to the directory named. "cd /" will take you to the root directory.


chmod {options}Changes the permission modes of a file. If you type "ls -l" in a directory, you might get something like this:


drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
drwxr-xr-- 2 ertle 512 Jun22 12:26 X/
drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
-rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
-rw-r--r-- 1 ertle 747 Nov 21 1992 profile
-rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*

The first part of the line tells you the file"s permissions. For example, the "X" file permissions start with a "d" which tells that it is a directory. The next three characters, "rwx" show that the owner has read, write, and execute permissions on this file. The next three characters, "r-x" shows that people in the same group have read and execute permission on the file. Finally, the last three characters "r-" show that everyone else only has read permission on that file ( To be able to enter a directory, you need read AND execute permission ). Users can use "chmod" to change these permissions. If the user didn"t want anybody else to be able to enter the "X" directory, they would change the permissions to look like those of the LaTeX directory, like this : "chmod og-rx X" - this means remove the read ("r" ) and execute ("x") permissions from the group ("g") and others ("o").


cmp {file1} {file2} Compares the contents of two files from each other. Reports the first different character found, and the line number.


cp {filename(s)}{path}Copies files from one directory/filename to another. "cp f1 f2" makes a file "f2" identical to "f1". "cp *.c src/" copies all files that end in ".c" into the "src" subdirectory.


ctags Creates a tags file for use with ex and vi. A tags file gives the location of functions and type definitions in a group of files. ex and vi use entries in the tags file to locate and display a definition.


date Shows current date and time.


dbx {executable}Source level debugger. In order to use this, you must use the "-g" option when compiling your source code. Allows you to set break-points, single step through the program, etc.


diff {file1} {file2} Displays all the differences between two files or directories to the screen.


elm {login-name}Runs a screen oriented mail reader. With a "login-name", starts elm to send mail to "login-name". Otherwise, it starts elm for an interactive session.


emacs {filename}Runs the most recent version of the text editor named EMACS ( produced by the GNU project ). If filename is present, it will start editing that file. Type "-x -h t" to start a tutorial. "-x -c" will exit from emacs.


env Prints out the values for all the current environment variables. Some typical environment variables are "DISPLAY", "EDITOR", and "PRINTER".


xemacs {filename}An X version of emacs.


file filename(s) Looks at "filename(s)" and tells what type of files they are. This is useful in checking a file to be sure that it is text before you "cat" it out ( using "cat" on binary files can be a bummer ). Example:


[email protected] (55)> file *
useful.dvi: data
useful.hlp: English text
useful.tex: ascii text
xwin.dvi: data
xwin.tex: English text
[email protected] (56)>

find Searches the named directory and it"s sub-directories for files. Most frequently called like this:


find ./ -name "t*" -print

Which searches the current directory ( and all of its sub-directories ) for any files that begin with the letter "t" and then prints them out. If you are looking for a specific filename, then replace "t*" with "filename", and "find" will print out all incidences of this file.


finger {login-name}Without a "login-name", finger shows who is currently logged on the system, with limited information about them. With a "login-name" you get more detailed info, along with anything that is in that person"s ".plan" file.


ftp {address}File Transfer Program. "ftp" transfers files to and from a remote network site. There are many ftp-sites that will let you log in as "anonymous" and get software/data/documents from them for free. After connecting, "ls" will print out the files in the current directory, and "get filename" will transfer the named file into your local directory. Be sure to type "binary" before transferring non-ascii ( executable, compressed, archived, etc ) files. To exit "ftp" type "bye". See also "xarchie".


g++ GNU project"s compiler for the C++ language. Parameters are similar to those of "cc". A typical invocation might be "g++ -g filename.cpp -o executablename -llib". More information available under "libg++" in the emacs information browser ( M-x info while in emacs ).


gcc GNU project"s compiler for the C language. Command line parameters are mostly similar to those of "cc". More information available under "gcc" in the emacs information browser ( M-x info while in emacs ).


gdb GNU project"s source level debugger. Must use the "-g" command line option when compiling to use this debugger. This debugger is superior to dbx when called from inside emacs ( M-x gdb ) because it gives you a full-screen look at the source code instead of line by line, and allows you to move around and make break-points in the source file. More information available under "gdb" in the emacs information browser ( M-x info while in emacs ).


ghostview {filename.ps}X PostScript previewer. PostScript is a text processing and graphics language, and ghostview is handy for looking at the resulting page or picture before you send it to the printer.


gossip Anonymous local message center.


ispell filename Interactively checks the spelling of the named file, giving logical alternatives to the misspelled words. Type "?" to get help. "ispell" can be accessed from the command line, and also through emacs with M-x ispell-buffer.


jobs Shows backgrounded (-z"ed) processes with pid #"s. If you use "jobs" to find the processes that you have suspended or are running in the background, what you get back might look like the following:


[1] 21998 Suspended emacs useful.tex
[2] - 22804 Suspended (signal) elm
[3] + 22808 Suspended badb

jove {filename}Johnathan"s Own Version of Emacs. Another emacs editor. Jove doesn"t have as many features as GNU"s emacs, but some people prefer it. -x -c to exit.


less filename Displays file with minimal space. kermit File transfer program. Allows you to transfer files between computers - your PC at home to/from the computers at school, for instance. For more information, look in the online manual pages.


ln -s {source} {dest} Creates a symbolic link from {source} to {dest}. {Source} can be a directory or a file.
Allows you to move around with ease instead of using long and complicated path names.


logout Exits and disconnects your network connection.


lpq {-Pprintername}Reports all print jobs in the queue for the named printer. If no printer is named with -Pprintername, but the "PRINTER" environment variable is set to a printer name, "lpq" will report on that printer.


lpr {-Pprintername}filename Queues file "filename" to be printed on "printer". If no printer is specified with -Pprintername, but the "PRINTER" environment variable is set, then the job will be queued on that printer.


lprm {-Pprinter}{job-number}Lprm removes a job or jobs from a printer"s spooling queue ( i.e. it stops it from being printed or printing out the rest of the way ). Typically, you"d get the job number from the "lpq" command, and then use lprm to stop that job.


ls {directory}Shows directory listing. If no "directory" is specified, "ls" prints the names of the files in the current directory. ls -l {directory}Shows long directory listing. If you type "ls -l" in a directory, you might get something like this:


drwx------ 3 ertle 512 Jul 16 13:38 LaTeX/
drwxr-xr-- 2 ertle 512 Jun 22 12:26 X/
drwxr-xr-x 3 ertle 512 Jul 13 16:29 Xroff/
-rw-r--r-- 1 ertle 373 Oct 3 1992 o.me
-rw-r--r-- 1 ertle 747 Nov 21 1992 profile
-rwxr-xr-x 1 ertle 244 Jul 16 23:44 zap*

The first part of the line tells you the file"s permissions. For example, the "X" file permissions start with a "d" which tells that it is a directory. The next three characters, "rwx" show that the owner has read, write, and execute permissions on this file. The next three characters, "r-x" shows that people in the same group have read and execute permission on the file. Finally, the last three characters "r-" show that everyone else only has read permission on that file ( To be able to enter a directory, you need read AND execute permission )


mail {login-name}Read or send mail messages. If no "login-name" is specified, "mail" checks to see if you have any mail in your mail box. With a "login-name", "mail" will let you type in a message to send to that person. For more advanced mail processing, you might try "elm" or "pine" at the command line, or "M-x mail" in emacs.


mkdir dirname Makes a sub-directory named "dirname" in the current directory.


man -k pattern Shows all manual entries which have "pattern" in their description.


man {section}name Shows the full manual page entry for "name". Without a section number, "man" may give you any or all man pages for that "name". For example, "man write" will give you the manual pages for the write command, and "man 2 write" will give you the system call for "write" ( usually from the C or Pascal programming language ).


more filename Displays the contents of a file with pagebreaks. Usefull to use "file" first so you don"t display garbage. mv filename path Moves "filename" to "path". This might consist of a simple renaming of the file, "mv file1 file2", moving the file to a new directory, "mv file1 /tmp/", or both "mv file1 /tmp/file2".


pine Full featured graphical mail reader/sender. "pine" will read your mail, "pine username" will prepare a message to "username".


printers Shows available printers and current status.


ps {options}"ps" reports that status of some or all of the processes currently running on the system. With no command line parameters, "ps" only shows processes that belong to you and that are attached to a controlling terminal.


pwd Shows current working directory path.


quota -v Shows current disk usage and limits.


rm filename(s) Removes files. Careful with this one - it is irreversible. It is usually aliased ( in a user"s .cshrc file ) to "rm -i" which insures that "rm" asks you if you are sure that you want to remove the named file.


rmdir dirname Removes the directory "dirname".


rupall Reports that status of local compute servers.


rwhoSimilar to "who", but shows who is logged onto all emba machines as well as the local machine. Without "-a", rwho shows all the people with under one hour idle time. With the "-a", rwho shows everybody that is logged on.



setenv Sets environment variables. Most frequently used to tell X which display you are on with "setenv DISPLAY displayname:0". Also used in .cshrc file to set "EDITOR" and "PRINTER" environment variables. This tells programs which editor you prefer, and which printer you want your output to be printed on.


spell {filename}Checks the spelling of the words in the standard input by default, checks words in "filename" if a name is supplied on the command line. If a word is misspelled it is printed to stdout ( usually the screen ).


trn Threaded, full page network news reader. Quicker than vn.


tin Threaded, full page network news reader. Easier to use than trn.


vi {filename}Runs the screen oriented text editor named "vi". If a filename is specified, you will be editing that file. Type "[ESC]:q!" to exit without making any changes.


vn Runs the screen oriented network news program. Old and slow - maybe try "trn" or "tin".



whereis {command} Reports the directory in which the {command} binary redides.


which {command} Reports the directory from which the {command} would be run if it was given as a command line argument.


who Shows who is currently logged on the system. The "w" command does the same thing, but gives slightly different info.


write loginname Send a message to another user. Each line will be sent to the other person as you hit the carriage-return. Press -D to end the message. Write won"t work if the other user has typed "mesg n".


xbiff X mailbox flag. The xbiff program displays a little image of a mailbox. When there is no mail, the flag on the mailbox is down. When mail arrives, the flag goes up and the mailbox beeps. This program must be started on one of the machines that you receive mail on. This will be one of the Suns ( griffin, sadye, newton, etc ) for most people.


xcalc X scientific calculator.


xcalendar X calendar. Interactive calendar program with a notebook capability.


xclock X clock.


xforecast X interface to national weather forecast.


xgdb X interface to the gdb debugger.


xman X interface to the online manual pages.


yppasswd Interactively changes your password.



Click Here for more advanced UNIX commands.


Ref :: http://www.thaibsd.com/webboard/show.php?Category=thaibsd&No=5488

บันทึกนี้เขียนที่ GotoKnow โดย 

หมายเลขบันทึก: 24098
เขียน:
แก้ไข:
อ่าน:
สัญญาอนุญาต: สงวนสิทธิ์ทุกประการ

ความเห็น (0)