CentOS Up & Running


Package Manager:
CentOS uses rpm packages. The yum utility handles resolving rpm package dependencies.
sudo yum update
Install wget:
The wget utility handles recursively downloading from a remote server.
sudo yum install wget
Install tar:
The tar utility handles tarballs.
sudo yum install tar
Alias commands:
Use alias to simplify command line usage by mapping commands to symbols with which you maybe more familiar.
alias cls = clear

Symbolic linking:
A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.
ln -s /etc/sysconfig/network-scripts/ network

Networking:
By default it appears the CentOS minimal install does not have networking enabled. The following commands will help you determine if the network interface is up and, if not, to help you to configure it.
Note: If you are using virtual box to host your Virtual Machine set the networking adapter to Bridged Adapter. Under the advanced tab you will be able to obtain the MAC address  necessary for the instructions below.
ifup eth0
ifdown eth0

dhcpcd -k eth0
dhcpcd -d eth0

iplink show

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
MACADDR=XX:XX:XX:XX:XX:XX
HWADDR=XX:XX:XX:XX:XX:XX

vim /etc/sysconfig/network
NETWORKING=yes

ip addr show eth0
VIM/VI:
Used to edit configuration and scripts.
h<- j="" k="" l-="">
ESC(Commad Mode) : (Extended mode- accepts commands)
wq (write | quit) w [filename]
yy (copy) yw(copy word) [number]+yw = 3yw (copy 3 words)
p  (paste line below | paste word after) P (paste line above | paste line before) - depends on if you used yy or yw
D  (delete to end of line) dd (delete) dw(delete word) cw(clear word and insert) dd(delete line)
Shift+I (insert)
Shift+R  (replace)
Shift+A(append at the end of the document)
0 (line start)
g (start of doc)
[[line number]G] (goto line number | end of doc)
r (read in)
![commad](output of command) r!date ~ read output of date 
i(insert to the left)
a(append to the right)
w(move word by word right)
b(move word by word to the left)
q(quit)
quit! (quit without saving)
quit (quit and save buffer and original)
Working with tarballs:
Use wget to download tarballs
wget [url]
Use tar to extract and decompress tarballs exclude the z parameter if the tarball is not compressed (tar.gz)
tar -zxvf [filename]
x - extract
z - gunzip the input
f - Read from a file, not stdin
Installing Java:
find /usr -name java
# yum search java | grep 'java-'
export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
echo $JAVA_HOME
# yum install java-1.7.0-openjdk.x86_64
Command line with grep and awk:
Linux supports piping the stdout from one command to the stdin of another using the pipe operator ( | ). This makes it easy to chain commands together to accomplish complex tasks. Among the commands you will find yourself using most often are grep and awk. The grep command is used to search for a particular symbol and awk is used to tokenize a string. To escape a bad command use (Control + Z).
find -name bin | grep local
find -name bin | awk -F / '{print $3}'
find -name bin | grep local | awk -F / '{print $3}'
List directory contents:
ls
ls | more
ls | less
Change directory :
cd /opt
cd ..
Find a file or directory:
find -name [name]
Delete a file / directory / symbolic link :
rm [name]
List Kernel Version:
uname -r
List Permissions:

rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000

and so on...

rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-x = 101 in binary = 5
r-- = 100 in binary = 4
ls -l [file|directory]
Change File/Directory Permissions:
chmod 7 7 7 [file|directory]
      | | | 
      | | |______ permissions for all other users
      | |________ permissions for group owning the file
      |__________ permissions for owner
Check File System Disk Space Usage:
df
Mount cdrom drive:
 mkdir media/cdrom
mount -r /dev/cdrom /media/cdrom

Install VirtualBox Guest Additions:
yum update yum install gcc yum install kernel-devel yum install bzip2 mount -r /dev/cdrom /media/cdrom sh /media/cdrom/VBoxLinuxAdditions.run

Open a port in the firewall:
firewall-cmd --zone=public --add-port=80/tcp --permanent sudo firewall-cmd --reload

Power options:
poweroff
reboot
halt
shutdown

Comments

Popular posts from this blog

Finding Your Company's Voice (Part 1)