RHCSA Exam EX200 Cheat Sheet Part 1

Below is the cheat sheet that my friend has kindly shared. Enjoy!

Cheat Sheet Part 1

File Compression

To compress files using tarball into tgz format

tar -czvf name.tar files

To view files in tarball file

tar -tf filename

To decompress a tarball

tar -xzvf filename

Sudo

To edit sudo config

visudo

Input & Output redirection

Output to a file, >> will append while > will overwritten

hostname >> file.txt

Input to a command then redirect the output on another file

In this example, send spelling.txt to spell command and redirect the output on mispelled.txt

spell < spelling.txt > mispelled.txt

Output the error to a file, 2> represent redirecting the errors

ls me.txt 2> output.txt

^ means the line will need to being with the word root

grep '^root" /etc/passwd

-n = print line number,

grep -n '[aA]pple' file.txt

grep the line does ends with /sbin/nologin

grep '/sbin/nologin$' /etc/passwd

grep the lines without the text nologin

grep -v '/sbin/nologin$' /etc/passwd

alter a file using search and replace

sed 's/speling/spelling/' spelling.txt > corrected.txt

User/Group management

GUI Tool

system-config-user

Add user account

useradd -c "full name" username

Add user account /w C Shell

useradd -s /bin/tcsh username

Add user account under a specify folder

useradd -c "full name" -d /home/accounting/username username

Add user name + group assignment

useradd -G groupname username

Add user /w password

useradd -p password username

Change user id

usermod -u UID username

Change user name

usermod -l newname oldname

Remove user account along with user’s directory and mailbox file

userdel -r username

Remove user’s directory

rm -rf /home/username

Modify user’s info

usermod -c "full name" username

Password change

passwd username

Password lock

passwd -l username

Password unlock

passwd -u username

Set password age for 90 days

chage -M 90 username

Set password never expire

chage -M -1 username

Set password to expire on specify date

chage -E 2012-01-01 username

Set warning 2 days prior to password expiration

chage -W 2 username

List password policy

chage -l username

Add a group

groupadd groupname

Add user to a group

usermod -G groupname username

Make the group assignment effective without logout

newgrp groupname

Change UID

usermod -u UID username

List user’s belong group

groups

Change group name

groupmod -n newname oldname

Change group ID

groupmod -g 1000 groupname

Show user’s ID

id username

Assign a user as group administrator

gpasswd -A username groupname

Assign a user to a group by adminstrator

gpasswd -a username groupname

Remove a group

groupdel groupname

Permissions

Modify file / folder permission

chmod o+W file (o for others, add write permission)
chmod 600 file (remove all permission group and other)
chmod ugo+rwx (add rwx permissiom to user. group and other)
chmod ugo-rwx (remove rwx)
chmod g+s file

Change ownership

chown username filename (change user ownship)
chown username:groupname file (change user/grp ownership)
chgrp groupname file (change group ownership)
chown -R username directory change ownership recusively on directory)

Change immutable bit, make the file read only even root

chattr +i filename (+i for add, -i for remove)
list immutable bit
lsattr filename

Change directory permission for user collaboration

chmond 2070 directory(2 means group will have the ownership of file)

Networking

Assign ip address to an interface (won’t survive after a reboot)

ifconfig eth1 x.x.x.x netmask x.x.x.x

Shut/bring up an interface

ifdown/ifup eth1

To view routing table

route
ip route

To add default route

route add default gw x.x.x.x dev eth1

To view ip details

ip addr show
ip -s link
ifconfig

To get ip address from dhcp

dhclient eth1

Iptables

To list rule

iptables -L

To flush the rules

iptables -F

To save the changes

service iptables save

To add a rule (accept a traffic of tcp port 21)

iptables -I INPUT -p tcp --dport 21 -j ACCEPT

To remove a rule

iptables -D INPUT -p tcp --dport 21 -j ACCEPT

GUI TOOL

um install system-config-firewall
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s