You are on page 1of 4

CentOS System Administrator

Prep
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
unencrypted
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@192.168.1.85
logout
Connect to a single GUI app:
command : ssh -X spower@kermit.brainofshwan.com
xeyes (<- this is just a sample program)
Connect to VNC over SSH:
command: ssh -L 5900:192.168.1.85:5900 192.168.1.85
or ssh -L 5999:192.168.1.85:5900 192.168.1.85
atfter when you connect thrrough VNC (localhost:5900 or
localhost:5999)

Reboots & Runlevels


0
1
2
3
4
5
6

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)
Reboot

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.
commands:
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)
runlevel
<- shows the currently in and the previous
runlevel)
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


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

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


controlling
process
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
Command:
"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
--list
turn off (0) or on (1) at runlevels the serivces -> chkconfig <service
name> on -- level 35
chkconfig <service name> on
Logs:
/var/log/
boot.log -> boot messages
messages -> main system log
httpd -> Apache log files
samba -> Samba log files

Partitions & Logical Volumes


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

Physical Volumes:
pv
Volume Group:
vg
Logical Volume:
lv
Resize filesystem:
resize2fs
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>

You might also like