You are on page 1of 4

CentOS System Administrator

Manipulating Text I/O
Input/Output Redirection:
Every command has: command STDIN STDOUT STDERR
- Not all commands listen for STDIN
- By default:
- STDIN -> comes from keyboard
- STDOUT -> goes to console
- STDERR -> goes to console
I/O Redirection Symbols:
< : Redirect STDIN (0=assumed)
> : Redirect STDOUT (1=assumed)
2> : Redirect STDERR
| : pipe results into STDIN of a command
>> : this will append instead of overwriting
& : used if redirecting STDERR into STDOUT, or vice versa

Access Remote Systems

VNC - Remote GUI, full desktop (not encrypted), uPNP will open
traffic to Internet, uses port 5900
SSH - Remote terminal, text only
- OR single GUI app (can tunnel x-windows applications)
- OR tunnel VNC over SSH
- uses port 22
Connect with SSH:
command: ssh root@
Connect to a single GUI app:
command : ssh -X
xeyes (<- this is just a sample program)
Connect to VNC over SSH:
command: ssh -L 5900:
or ssh -L 5999:
atfter when you connect thrrough VNC (localhost:5900 or

Reboots & Runlevels


Halt (Shut Down)

Single user mode (Command line)
Multiuser, no network (Command line)
Multiuser, with network (Command line)
Not used (User Defined - Users can customize this runlevel)
Multiuser, network, x windows (Graphical Mode)

Using Runlevel with init and telinit and shutdown (telinit is the
proper way):
The init, telinit directly goes to the runlevel, while the shutdown
command send a warning to users on CLI.
telinit <number> <- switch to runlevel
shutdown <time> <- switch to runlevel 1
shutdown -r <time>
<- switch to runlevel 6
shutdown -h <time>
<- switch to runlevel 0
(time=now, it shut down immediately)
<- shows the currently in and the previous
change the default runlevel:
vim /etc/inittab
Change runlevel on bootup:
1. Go to GRUB Menu: press any key couple of times
2. Modify the kernel arguments before booting (edit the argument):
press "a"
3. type: 1 (goes to the single user mode)

Renicing and Killing Rogue Processes

top (displaying processes running on the system)
kill, killall (telling to end, reread configuration file, pause or
kill -9 PID
kill -9 <name of the program>
kill -9 <pattern>
pgrep (before pkill is used, pgrep is wise)
ps u
Kill Signals:

SIGHUP (1) - Hang-up detected on controlling terminal or death of

SIGINT (2) - Interrupt from keyboard
SIGQUIT (3) - Quit from keyboard
SIGABRT (6) - Abort signal from abort(3)
SIGKILL (9) - Kill signal
SIGTERM (15) - Termination signal
SIGCONT (19,18,25) - Continue if stopped
SIGSTOP (17,19,23) - Stop process
Nice Levels:
-20 -> Highest priority
0 -> Normal, default priority
19 -> Lowest priority
"nice -10" AND "nice -n 10" both are the same

Network Services and Their Log Files

/etc/init.d-> you can find the services here, which ones you can start
or stop
service <service name> start/stop/restart/status
cd /etc/rc -> every runlevel has their own rc folder (rc1.d,rc2.d....)
go to runlevel 5's services -> cd /etc/rc5.d
showing all services that are run or off, on runlevels -> chkconfig
turn off (0) or on (1) at runlevels the serivces -> chkconfig <service
name> on -- level 35
chkconfig <service name> on
boot.log -> boot messages
messages -> main system log
httpd -> Apache log files
samba -> Samba log files

Partitions & Logical Volumes

fdisk (fdisk /dev/sdb)
LVM (Logical Volume Manager):
Physical Volumes -> Volume Group -> Logical Volume

Physical Volumes:
Volume Group:
Logical Volume:
Resize filesystem:
Checking filesystem: df -h
mkfs. -> creating a filesystem (mkfs.ext4, mkfs.ext2)
mkdir /mnt/<a new folder name>
mount -t ext4 /dev/sdb3 /mnt/<a new folder name> -> mounting
the filesystem to a folder
umount /mnt/<a new folder name>
Encrypted partitions: LUKS (Linux Unified Key Setup):
First we need to create the encrypted partition and after we need to
add the filesystem.
cryptsetup luksFormat /dev/sbd3
cryptsetup luksOpen /dev/sdb3 <give a name for the device> <Mount this partition to an unencrypted way
cryptsetup luksClose <name of the device>