Pages

Sunday, May 11, 2014

RHCA - Understand and use essential tools

Use input-output redirection (>, >>, |, 2>, etc.).

Streams

standard input  - stdin  (0)
standard output - stdout (1)
standard error  - stderr (2)

$ find / -name  "*key*" 2> stderr
$ find / -name  "*key*" &> stdout_and_stderr

$ sort < file_name > sorted_file_name

Pipes

Pipes are used to redirect a stream from one program to another.


$ echo "10.128.8.143  sanbox1" | sudo tee -a /etc/hosts

Use grep and regular expressions to analyze text. 

grep, egrep, fgrep - prints lines matching a pattern. A regular expression is a special character string for describing a search pattern.

$ grep "letters"      /file/name
$ grep -r "letters"  /directory/name
$ grep -w "word"   /file/name
$ grep -v "letters"  /file/name
$ grep "^letters"   /file/name
$ grep "letters$"   /file/name
$ grep '^$'            /file/name

$ grep -E ( x | y ) /file/name
$ grep -E "(a)?b" /file/name

Access remote systems using ssh and VNC.

$ ssh sandbox01.lab -p 1022
$ ssh sandbox02.lab "ls -ltr"
$ ssh -t sandbox02.lab "screen -r"
$ ssh-copy-id sandbox02.lab

$ ssh -L 5901:localhost:5901 vnc-server.lab

$ vncviewer vnc-server:1
$ vncviewer vnc-server::501

$ ssh vnc-server
$ vncserver
$ vncviewer vnc-server <session #>

Log in and switch users in multiuser runlevels.

$ who -r
$ runlevel

/etc/inittab

        0 — Halt
        1 — Single-user text mode
        2 — Not used (user-definable)
        3 — Full multi-user text mode
        4 — Not used (user-definable)
        5 — Full multi-user graphical mode (with an X-based login screen)
        6 — Reboot

/sbin/chkconfig

su - <user name>

Archive, compress, unpack, and uncompress files using tar, star, gzip, and bzip2.


#  tar -cvf archive1.tar test-dir
echo "something" | sudo tee bar
echo "something" | sudo tee bar
echo "something" | sudo tee bar
echo "something" | sudo tee barecho "something" | sudo tee bar
echo "something" | sudo tee bar

No comments:

Post a Comment