cat
cat conCATanates a file (prints it in simple words) from standard input, file
or device to standard
output, file or device or program, checking the EOF (End Of File)
condition.
cat for example can:
print a text file to the terminal or redirect it to the parallel port,
add the output of a file to another one,
copy a file or device to a file or device,
pipe the output to a program to another program or dedirect it to a
fifo (first in - first out data channel) file
etc. meaning as many uses as you could imagine, considering the
transparency of Unices in general.
|
cd
cd changes to the absolute or the relative path specified.
cd mydir will go to
the current directory's subdirectory called "mydir" if exists.
cd .. will go one
parent dir up. cd ../../..
will go 3 parent dirs up.
cd - will go to the
last path we have been.
So, if we are in /home/micro we can do: cd ../../usr/lib and we will be
there.
Bash auto completion will help us a lot.
And if we do then: cd -
voila, we are in our home again.
If we redo: cd - we go
back to the /usr/lib directory.
|
cp
cp copies files or directories to an existing destination.
some options following "-" and optionally combined:
i makes the procedure interactive (cp will ask)
f forces the operation to be completed
r copies recursively (directories and contents inside them)
b makes backups of files to be overwriten.
|
find
find performs powerful file searching operations, considering not only
filename or extention but also ownerships, permissions, timestamps,
file types etc.
find /usr -name '*.html'
is an example.
find and grep are very powerful commands, especially when combined.
|
grep
Global Regular Expression Print finds a string in a file or standard
input.
issue ps -ef | grep
smbd and see if the SMB file sharing daemon is up.
or type grep -l lp0 /etc/*
to see which configuration files mention the parallel port 1.
grep -l gpm $(find /etc
-name 'rc.*')
instructs grep to find which files that begin with 'rc' in
/etc contain "gpm".
In other words: Which configuration files contain commands about the
General Purpose Mouse for Virtual Console Terminals!
This example shows another capability of shells and programs: the
(list) command compound method, in which the output of the program
(executed in a second shell) passes to another, not as output, but as
parameters.
For more about this issue, visit TrainMe
page and man
bash.
|
less
less is a text (ascii) browser that if configured properly can see
correctly more "complicated" formats, like html etc.
less is commonly user for 3 reasons:
1) to browse a text file
2) as an external viewer for man, to browse the man (manual) pages
3) to view the output of a program when the terminal is exceeded (so
lines are lost)
so try: less /etc/fstab , lspci -v | less
some options inside the program:
| q |
exits |
| s
<filename> |
saves
the output to a file |
| <enter>
|
goes
down a line |
| <down> |
goes
down a line |
| <right> |
goes
right if line width
exceeds terminal |
| <left> |
goes
left if
<right> is already used |
<space>
|
goes
a page down |
| <pgdown> |
goes
a page down |
page
up>
|
goes
a page up |
| <home> |
goes
up to the
beginning |
<end>
|
goes
down to the
end |
/
|
searches
for string |
n
|
searches
for
next match |
p
|
searches
for previous match |
:n
|
goes
to the next file when
browsing more than one files |
| :p |
goes
to the previous file
|
less, pico, vi and optionally emacs will be some of your best friends
to perform system administration tasks right from the terminal.
|
ls
ls lists contents of a path
Some options following "-" and optionally
combined:
a for hidden files
l for detailed listing
h for human readable output
etc.
so ls -lah /usr can combine all previous
parameters.
|
mkdir
mkdir makes directory (or multiple directories).
some options following "-" and optionally combined:
m also sets modes (permissions)
p makes the subdirectories missing. In this way, I can mkdir -p
/mnt/nfs/filer/home in one step. Normally, if /mnt/nfs did not exist,
the mkdir command would return error.
|
mv
mv moves files and directories to an existing destination.
some options following "-" and optionally combined:
i for interactive operation
f to force the operation.
|
pico
pico is the simplest text editor money can buy (it's free) for
GNU/Linux, *BSD etc.
pico is included in the pine package.
pico can be used to create and edit a new file (pico newfile) or edit
an old one (pico oldfile)
pico is excellent in creating and quickly editting text files, thus a
very useful tool for root considering global configuration files.
Outside pico, the -w parameter instructs to open a file and not wrap
lines.
Inside pico, some of the shortcuts are:
Ctrl o write out the file (save)
Ctrl x exit pico (will ask for file writing confirmation)
Ctrl w find a string inside the text
Ctrl k cut line(s)
Ctrl u uncut (paste) line(s)
nano (Nano'sANOther
editor) is almost identical to pico, useful for users who do not (or do
not wish to) have the pine package.
|
pwd
Prints Working Directory (the location in the filesystem we are
currently in)
Q: Why should I ask something I know?
A: There are cases we are so "deep" in the filesystem that giving
details about the location in the prompt is not practical any more:
micro@athlon:/mnt/disk1part1/home2/m/group1/micro/documents/media/videos$
(see the point?)
So, we just issue the "last dir" parameter in the prompt and use pwd
whenever we need to know:
micro@athlon:videos$ pwd
/mnt/disk1part1/home2/m/group1/micro/documents/media/videos
micro@athlon:videos$
Furthermore, pwd can be used in a script that needs to know our present
location:
initialdir=$(pwd)
cd /etc ; action1 ; action2
; action3
cd $initialdir
|
rm
rm removes files and directories' if specified.
some options following "-" and optionally combined:
i for interaction
f to force the operation
r for recursive operation (subdirectories)
if files are hard links to others, rm will erase only the specified
hard link, thus name of file, but not the other one.
if files are soft links to others, rm will erase only the soft link,
not the file itself.
|
watch
watch can periodically execute a terminal program (that would normally
output data and exit) while showing its output.
So, when you plug a usb device in, and want to make the kernel messages
constantly updating the screen, issue:
watch 'dmesg | tail'
This example shows also a
capability of shells and programs: the pipe, a method to pass a
program's output to another's input.
For more about this issue, visit TrainMe page.
|
wc
Word Count is designed to show in a most economic way lines words and
letters contained in a file or standard output.
micro@athlon:~$ cat /etc/fstab | wc (count newlines words and letters of
/etc/fstab)
25 112 1546
micro@athlon:~$ find /etc -name 'rc.*' | wc -l (how many are the rc.* configuration
files)
35
|
|
---------------- To Be
Continued
-------------------------
|