Basic commands for GNU/Linux - BSD (part 2)
February 27th, 2008 at 4:43pm |
Some more basic commands for GNU/Linux - BSD
Thanks to http://www.ssel.montana.edu/HowTo/adv_unix.html for this list!
Redirection
< , >
Processes
example, the “ls -l” command prints out all of the files in the current
directory, along with information about those files, and the “more” command
displays only one screenful of information at a time. If there are a lot
of files in the current directory, you might want to try “ls -l | more”,
which makes “ls -l” send all of it’s output to “more” which then displays
it one screenful at a time. Another useful one is “ps -ef | grep USERNAME”,
replacing USERNAME with the user you’re looking for: it will only show
the lines with that user in them.
to the specified file. For example, “ls -l > names.dat” will put the
names and permissions of all the files in the local directory into a file
named “names.dat”. If you don’t want to see any output from a command,
you can send the output to “/dev/null” ( “ls -l > /dev/null” would
send the names to “/dev/null”, though it doesn’t really serve a purpose
in this example ).
in the file and send it to a process as if it came from the standard input
( usually the keyboard ). For example, the “spell” program reads from
standard input and prints out the words that it thinks are misspelled.
So, you can type “spell<RET>”, then type in the words that you want
to check followed by <CTRL>-D ( the end of file mark ), and spell will
print out the misspelled words. If you wanted to check all of the words
in a file, you’d redirect the standard input to come from the file “spell
< filename”, and spell would read the file instead of the keyboard.
need input from the keyboard or output to the screen. Say the process is
“cat file1 file2 > file3” and the that file1 and file2 are large. This
could take a while before it finishes. To make it run in the background
( which will allow you to continue to work while it is running ), the easiest
thing to do would be to use the “&”, like so: “cat file1 file2 >
file3 &”.
“#” is replaces with a job number ) will re-enter a suspended process.
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
Where the first number ( in brackets ) is the job number, and typing “%1”
at the command line would cause you to re-enter the emacs job.
sends a termination signal to current process. This usually kills the current
process.
csh shell. <CTRL>-Z sends a terminal stop signal to the current process.
This allows you to temporarily exit a running process, and re-enter it
with “fg”. The “jobs” command will show you what processes you have
done this to. If the process doesn’t require input from the keyboard or
output to stdout ( usually the screen ), then after using “<CTRL>-Z”
you can make the process run in the background with “bg”.
LaTeX text processing programs. More information on TeX and LaTeX can be
found in the printed manuals, available for borrowing at the EMBA computer
facility. “-Pprintername” tells Dvi which printer to print out on. This
parameter isn’t necessary if you’ve set your “PRINTER” environment variable
(do this with the “setenv” command ).
text processing commands. For more information, look in the document formatting
portion of the printed manuals in room 252 - the “Nroff/Troff User’s manual”
and the “Troff Tutorial” are both worth looking at.
For more information, look in the document formatting portion of the printed
manuals in Votey room 252 - the “Nroff/Troff User’s manual” and the “Troff
Tutorial” are both worth looking at. “-Pprintername” specifies which
printer to send the print job to ( i.e. -Pembalaz ). This parameter isn’t
necessary if you’ve set your “PRINTER” environment variable ( do this
with the “setenv” command ).
“awk” can run it’s own script files ( “awk -f scriptfile inputfile”
would run the script file on the input file ), or it can accept quick scripts
on the command line - “awk ‘length < 80′ filename” prints to stdout
( usually the screen ) all of the lines in the file “filename” that are
shorter than 80 characters.
information supplied on the CRSP and Compustat tapes. Type “badb” at
the command line, and choose the data base that you wish to enter. It is
interactive, and there is on-line help.
from the keyboard or output to the screen, then you can make it run in
the background. Say the process is “cat file1 file2 > file3” and the
that file1 and file2 are large. This could take a while before it finishes.
If you start the process, and then realize that you want to make it run
in the background ( which will allow you to continue to work while it is
running ), type “<CTRL>-Z” and then “bg”. The process is now backgrounded.
You can see the status of the job with “jobs” or “ps”.
and backgrounds. (best if run from SGI machine, and SUN server (Newton,
Griffin, Sadye, ect …)
RGB looks like. Runs from SGI machines.
possible, each file is replaced by one with the extension “.Z”, while
keeping the same ownership modes. If “filename” isn’t specified, compress
will compress its standard input.
news, current and historical stock quotes, the MCI Mail service, Official
Airline Guide flight and fare information, as well as detailed corporate
and industry data. Also available in this unique service are a wide variety
of general interest databases, including sports and weather reports, a
computerized shopping service, movie reviews, a lexicon of investment terminology
and an encyclopedia.
location of functions and type definitions in a group of files. Emacs and
epoch use entries in the tags file to locate and display a definition.
To go to a function definition in emacs, type “M-.” ( Meta period ).
This will ask you the name of the function that you wish to find. Type
it in and press return. If what you typed in is found at the beginning
of a number of functions, you might not get the correct one on the first
try. If this is the case, keep typing “M-,” ( Meta comma ) until you
reach the one that you want.
to find the processes that you have suspended or 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
Simply typing “fg” at the command line will put you back in the process
that has the “+” in the 2nd column, in this case it would be the “badb”
process. “fg %2” will put you back in the “elm” process.
top
a regular expression. If no “filename” is given, grep searches it’s standard
input for the the string or expression. When grep finds the requested string
or expression, it prints out the line that contains it along with the filename
of the file that the line is from. Example: “grep chance *” will search
all of the files in the current directory for the word “chance”.
to those of tar. gtar has the added advantage of not trying to keep the
original file ownership of files being extracted. All files are changed
to belong to the person doing the extraction. To create an archive, you
might type “gtar cvf archname file1 file2 file3”, which would put file1-3
in the archive named archname. “c” of “cvf archname” in the command
line means create the named archive, “v” means verbose - print names
of the files and the operation performed on them, and the “f archname”
gives the name of the archive that you want to do the operations on. “gtar
tvf archname” will print out the names of all of the files in the archive,
“gtar xvf archname” will extract all of the files from archname, and
“gtar xvf archname filename” will extract only “filename” from the
archive, provided that it is in the archive in the first place.
available on the Sun machines. For more information look in the printed
manual pages.
See “jobs” and “ps” for information on how to find PID’s or job numbers.
So, if the PID is 12345, then “kill -9 12345” will kill the job. If the
job number is 5, then “kill -9 %5” will kill it.
and “latex” compiles this language into a device independent (dvi) representation
of the resulting document. “latex” will report errors and, if there are
none, give you a file named “filename.dvi”. This file can be previewed
with “xdvi”, and may be printed out with “Dvi”. More information on
the LaTeX language is available in the LaTeX manual which you can borrow
from an EMBA counselor.
is an ASCII previewer for nroff/troff files, showing what the file will
look like when it is printed ( prints to stdout - usually the screen ).
This can be handy for looking at nroff/troff files that you are writing
“nroff filename | more”, or for looking at the manual pages that come
along with software that you get from the Internet “nroff -man filename
| more”. “Vroff” is a graphical previewer of nroff/troff files that
will show different fonts and point sizes ( which the nroff program won’t
).
new top directory. Use pushd to place new directories on the stack. If
the stack consists of the following ( leftmost is the top of the stack
): “/usr / /usr/local/bin”, then you will be in the “/usr” directory,
and typing popd will make the stack look like this: “/ /usr/local/bin”,
putting you in the root directory ( / ).
If “directory” isn’t specified, pushd swaps the two top directories on
the stack, placing you into whichever directory is now on the top of the
stack. Use popd to remove stack entries. If the directory stack looks like
this ( use “dirs” to print out the current directory stack, and the leftmost
directory is top of stack): “/ /bin”, and you type “pushd /usr/local/bin”,
then the new stack looks like this: “/usr/local/bin / /bin”, and you
will be in the /usr/local/bin directory. If you then type “pushd”, the
stack will look like this: “/ /usr/local/bin /bin” and you will be in
the root directory. Finally if you type “pushd +2” the stack will look
like this: “/bin / /usr/local/bin”, and you will be in the /bin directory.
from a file ( -f scriptfile ) or the command line ( -e script ). For example
“sed -e ’s/test/testing/g’ filename” will replace every instance of the
word “test” with the word “testing” and print the result to stdout
( usually the screen ).
“-n” command line option. Without a “filename”, sort works on the standard
input. Otherwise it sorts the lines in the file and writes the sorted output
to stdout ( usually the screen ).
Sometimes has permission problems when extracting files by maintaining
the ownership of the files in the archive. If you have this problem, try
“gtar”. To create an archive, you might type “tar cvf archname file1
file2 file3”, which would put file1-3 in the archive named archname. “c”
of “cvf archname” in the command line means create the named archive,
“v” means verbose - print names of the files and the operation performed
on them, and the “f archname” gives the name of the archive that you
want to do the operations on. “tar tvf archname” will print out the names
of all of the files in the archive, “tar xvf archname” will extract all
of the files from archname, and “tar xvf archname filename” will extract
only “filename” from the archive, provided that it is in the archive
in the first place.
(which automatically adds the “.Z” to the end of the filename).
changes binary files into ascii files so that they can be easily e-mailed
or posted to the news.
sent using mail(1) or posted to a news-group. If you don’t specify “source-file”,
then uuencode takes its input from standard-input. “uuencode” sends the
encoded output to stdout ( usually the screen ). When decoded using “uudecode”
the resulting file will be named “file-label”.
unset your “DISPLAY” environment variable ( “unsetenv DISPLAY” ), then
type “wp51”. For the X-windows version of wp51 you must first set your
“DISPLAY” environment variable ( “setenv DISPLAY dname:0”, where dname
is the name of the display that you are using ), and then you must tell
it where to find the appropriate fonts by typing “xset fp+ /usr/local/lib/X11/fonts/wp”
on the console of the machine that you are working on, then simply type
“wp51” at the command line in one of your Sun windows ( griffin, newton,
sadye ).
about files available for ftp anywhere on the Internet. ( i.e., it helps
you figure out where you can ftp a particular file from ). Say you want
to find out where you can ftp the gdb debugger from - you’d type “gdb”
in for the “Search Term:”, and then press return. Xarchie will then connect
to one of the archie servers ( which one can be controlled though the “settings”
menu ), and look for any file that it know about that contains the string
“gdb”. It will report the ftp servers, the directory, and the file found
on your screen. You can then use ftp to get the file if you want it.
Print This Post
|
Email This Post
