- System Commands:
-
|
INIT & Run Levels
- INIT
Manpage
|
- At any given time, the system is in one of eight possible
run levels. A run level is a software configuration under which
only a selected group of processes exists. Processes spawned
by INIT for each of these run levels are defined in /etc/inittab.
INIT can be in one of eight run levels, 0-6 and S or s (S and
s are identical).
-
|
init 0 |
Go into firmware. |
|
init 1 |
Put the system in system administrator mode. All local file systems
are mounted. Only a small set of essen- tial kernel processes
are left running. This mode is for administrative tasks such
as installing optional utility packages. All files are accessible
and no users are logged in on the system. |
|
init 2 |
Put the system in multi-user mode. All multi-user environment
terminal processes and daemons are spawned. This state is commonly
referred to as the multi-user state. |
|
init 3 |
Extend multi-user mode by making local resources available over
the network. |
|
init 4 |
Is available to be defined as an alternative multi- user environment
configuration. It is not necessary for system operation and is
usually not used. |
|
init 5 |
Shut the machine down so that it is safe to remove the power.
Have the machine remove power, if possible. |
|
init 6 |
Stop the operating system and reboot to the state defined by
the initdefault entry in /etc/inittab. |
|
init a, b, c |
process only those /etc/inittab entries having the a, b, or c
run level set. These are pseudo-states, which may be defined
to run certain commands, but which do not cause the current run
level to change. |
|
init Q, q |
Re-examine /etc/inittab. |
|
init S, s |
Enter single-user mode. This is the only run level that doesn't
require the existence of a properly for- matted /etc/inittab
file. If this file does not exist, then by default, the only
legal run level that init can enter is the single-user mode.
When in single-user mode, the filesystems required for basic
system operation will be mounted. When the system comes down
to single-user mode, these file systems will remain mounted (even
if provided by a remote file server), and any other local filesystems
will also be left mounted. During the transition down to single-
user mode, all processes started by init or init.d scripts that
should only be running in multi-user |
- Processes that must start up during a run level are defined
in the /etc/rc*.d directory. (ie: /etc/rc3.d). The processes
are defined with an "S##" to designate a start script
and the process order (##). For instance S01-whatever will start
before S99-whatever. There is a specific order to the start ups.
Certain services must be started before you can begin application
start ups for instance. So you need to be familiar with what's
starting on a server before you add a start up process to the
run control list.
- For the shutdown run levels (ie: init 0), processes are placed
in their corresponding runlevel directory (ie: rc0.d). Process
scripts are defined as "K##", to designate a kill script
and the process order (##) for shutdowns.
|
|
Server start up mountings |
- view the vfstabb file
|
|
NFS Mounts on the box |
- > df -k : grep
|
|
Display Disk Usage |
- View all allocations on the server
- from the root du > filename
- filename = the name of the file that will contain the generated
report.
- If no name is given, the report will be displayed on the
screen.
-
- View allocations from the root:
- > du -sk
- s = space
- k - kilobytes
- View allocations for a specific directory
- > du -sk directory name
- or
- > cd into the desired directory
- > du -sk .
|
- Display status of disk space on file
systems
- ie: Find free space in a partition
|
- View the entire box
- > df -k -F ufs
- View a specific directory
- > df -k .
|
|
Display current ports being used |
- View the entire box
- > netstat
-
- View a specific port
- > netstat -an | grep port#
-
- To see who's using the specified port
- > telent boxname port#
|
|
Change users |
- View all allocations on the server
- login as yourself
- > su user
-
- To login as a super user for root
- > su - root
-
- To see what user you're logged in as
- > whoami
|
|
Display the box you're logged onto |
- uname -a
Will return, the type of OS, the name of the box, the current
patch level, the type of hardware. Ie:
SunOS mybox002 5.8 Generic_117350-18 sun4u sparc SUNW,Sun-Fire-280R
|
|
Find a file on a server |
- To find a specific file on a server,
- Go to the file system you think the file might be in. Ie:
/MYFiles/
- find . -name "ABC.file" -type
f
Will return:
./App/WEB-INF/classes/ABC.file
./WEB-INF/classes/ABC.file
./WEB-INF/lib/ABC.file
-
- To find the same file, with it's details:
- Go to the file system you think the file might be in. Ie:
/MYFiles/
- find . -name "ABC.file" -type
f -ls
Will return:
3682565 1 -rwxrwxr-x 1 mgrid other 117 Nov 8 2002 ./App/WEB-INF/classes/ABC.file
3682571 4 -rwxrwxr-x 1 mgrid other 3196 Nov 10 2002 ./WEB-INF/classes/ABC.file
3655683 1 -rwxrwxr-x 1 mgrid other 108 Nov 10 2002 ./WEB-INF/lib/ABC.file
|
-
- File Manipulation Commands:
|
Copy directories / files |
- Copy a file
- > cp source-file destination-file
-
- Copy a file and maintain it's permissions (if you're not
the owner, you need to be root)
- > cp -p source-file destination-file
-
- Copy a directory and it's contents
- > cp -r directory-source
directory-destination
|
|
Display directory contents |
- List all the files in a directory (lists subdirectories and
files)
- > ls
-
- List all the files in a directory, with their attributes
(lists subdirectories and files)
- > ls -la
-
- List all the subdirectories in a directory
- > ls -d
-
- List all the subdirectories in a directory, with their attributes
- > ls -lad
-
- List certain files in a directory (ie: only the files starting
with http)
- > ls -la https*
|
- Find a string in multiple files
- egrep
|
- To find a specified string within multiple files, use egrep.
- This will look in all the files in the current directory
for the string "Listen". The results returned will
be {filename : line containing the searched for string}
- > egrep Listen *
- will return:
- vhost-order:Listen 6300
- vhost-purchase:Listen 6301
- vhost-delivery:Listen 6302
|
- Tar and gzip
- Tar ManPage
|
- Create a tar file (tarball)
- > tar -cvf filename.tar directory/file-to-tar
- ie: tar -cvf vanilla.tar /www/covalent
-
- To create a tar file with only certain files or directories,
use an include file:
- Create (with VI) a file named include that contains the full
path of the directories, (and files) to be included.
- > cd to the directory where
the tar will be stored.
- > vi include
- > insert the directories
(1 on each line - NO spaces or trailing spaces)
- :> wq!
- the file "include" looks like this:
- /www/covalent
- /www/approot/vanilla
- /www/docroot/vanilla
- Create the tar file:
- > tar -cvf filename.tar -I
include-file name created in the previous steps.
- ie: tar -cvf vanilla.tar -I include
-
- To view the contents of the tar file you just created:
- > tar -tvf filename.tar
- If you need to see one page of the contents at a time:
- > tar -tvf filename.tar |
more
- If you need to go back after a page has been displayed, use
cntl + b
-
- To extract a tar:
- Make sure you're in the directory where you want to explode
the contents of the tar. (if you used the full path name to create
the tar, you can be anywhere when it explodes).
- > tar -cvf filename.tar
-
- To compress a tar file into a .gz file
- Note: gzip will delete .tar file once the .tar.gz file has
been created, so only the .gz remains on the box.
- > gzip filename.tar
-
- To explode a .gz file
- You have to uncompress a .gz file before you can untar it.
- > gunzip filename.tar.gz
- > tar -xvf filename.tar
|
- Find a string in compressed .gz
files
- gzmore
|
- To find a specified string within compressed files: *.gz
- This command works similarly to the more command, and uses
basically the same parameters.
- > gzmore *2005* | grep /lmpweb
- will return the lines in all the *2005* files within the
selected directory that contain the /lmpweb directive.
|
|