Documente Academic
Documente Profesional
Documente Cultură
Grubby
adalah salah satu tool atau command yang digunakan dalam memaintain grub versi 2.
# Untuk menjadi permanent lakukan perintah dibawah ini:
[root@localhost ~]# grub2mkconfig o /boot/grub2/grub.cfg
[root@localhost ~]# reboot
Seting Grub versi 1 di CentOS-6,
[root@localhost ~]# vi /boot/grub/menu.lst
default=1 > urutan default title
timeout=10 > waktu
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32358.el6.x86_64) > nama title
root (hd0,0) > menyatakan /root berada hd0=hardisk pertama
dan ,0 = partisi pertama
kernel /boot/vmlinuz2.6.32358.el6.x86_64 ro root=UUID=
rhgb quiet > lokasi kernel
initrd /boot/initramfs2.6.32358.el6.x86_64.img > lokasi
image kernel
title CentOS BUDI
root (hd0,0)
kernel /boot/vmlinuz2.6.32358.el6.x86_64 ro
root=UUID=b0c24ec8 rhgb quiet
initrd /boot/initramfs2.6.32358.el6.x86_64.img
title Cen
root (hd0,0)
kernel /boot/vmlinuz2.6.32358.el6.x86_64 ro
root=UUID=b0c24ec8e4 rhgb quiet
initrd /boot/initramfs2.6.32358.el6.x86_64.img
Reset Password Root
1. Masuk ke bootloader
2. Tahan menu bootloader dengan menggerakan tanda arah panah atas dan kebawah
3. Tekan esc pada menu bootloader
4. Tekan kembali e dan highlight/sorot ke bagian kernel
5. Tambahkan di bagian akhir “linux16...” kernel, seperti : “ ...rw init=/bin/bash”.
Dah hapus option "rhgb", "quiet", "LANG=***", seperti contoh dibawah ini :
Sudo adalah singkatan dari Super User DO, yang diartikan sebuah user biasa yang memiliki
privileges administrator.
su = switch user
Untuk memberikan sebuah privileges user admin, kita bisa mengubah user tersebut dengan perintah
[root@localhost ~]# usermod -G wheel sandi
keterangan:
usermod : command user mode
wheel : group administrator yang dimiliki oleh CentOS
sandi : user biasa
Jika error disebabkan Failed dependencies, install terlebih dahulu paket dependency tersebut,
contoh
error: Failed dependencies:
libSM.so.6 is needed by teamviewer-11.0.57095-0.i686
libasound.so.2 is needed by teamviewer-11.0.57095-0.i686
libdbus-1.so.3 is needed by teamviewer-11.0.57095-0.i686
libjpeg.so.62 is needed by teamviewer-11.0.57095-0.i686
libpng12.so.0 is needed by teamviewer-11.0.57095-0.i686
[root@localhost ~]# yum install y teamviewer.i686.rpm
sukses
Install Paket Tarbal (.TAR)
Langkah instalasi dari source pidgin
2. Configure.
[root@localhost ~]# ./configure prefix=/usr/local/pidgin
disablescreensaver disablestartupnotification withpython
disablevv disableidn disableavahi disablesm
3. Compile.
[root@localhost ~]# make
4. Copy
[root@localhost ~]# make install
5. Testing
[root@localhost ~]# /usr/local/pidgin/bin/pidgin
Installation HP LaserJet P1005, P1006, P1007, P1008, P1505
4. Download firmware
– Get HP LaserJet P1005 firmware file –
[root@localhost foo2zjs]# ./getweb P1005
note: to get other firmware with other typical printer
5. Install driver
[root@localhost foo2zjs]# make install
8. Configure your printer using gnome printer configuration, click System -> Administration ->
Printing
9. Another way, you can run printer administration using CUPS at http://localhost:631/
Execute file :
[student@localhost ~]$ ./case.sh
atau
[student@localhost ~]$ sh case.sh
declare.sh
[student@localhost ~]$ vi declare.sh
#!/bin/bash
declare i num
num=1
num=5+num
echo $num
floating.sh
[student@localhost ~]$ vi floating.sh
#!/bin/bash
num=`echo "scale=5; 13 / 2" | bc`
echo $num
fungsi.sh
[student@localhost ~]$ vi fungsi.sh
#!/bin/bash
# skrip sederhana demonstrasi penggunaan fungsi
function keluar ()
{
exit
}
function cetak ()
{
echo "hello world"
}
if.sh
[student@localhost ~]$ vi if.sh
#!/bin/bash
echo "Hello world"
echo "ini shell script pertama saya!"
if2.sh
[student@localhost ~]$ vi if2.sh
#!/bin/bash
echo n "Masukkan sebuah password : "
read password
if [ "$password" = "asli" ]; then
echo "you're right."
else
echo "you're wrong."
fi
kegiatan.sh
[student@localhost ~]$ vi kegiatan.sh
#!/bin/bash
echo n "sedanga apa?"
read kegiatan
echo "selamat $kegiatan!"
let.sh
[student@localhost ~]$ vi let.sh
#!/bin/bash
num=1
let num=5+num
echo $num
let2.sh
[student@localhost ~]$ vi let2.sh
#!/bin/bash
num=1
(( num+=5 ))
echo $num
login.sh
[student@localhost ~]$ vi login.sh
#!/bin/bash
user=`whoami`
echo "Anda login dengan account : $user"
while.sh
[student@localhost ~]$ vi while.sh
#!/bin/bash
COUNTER=0
while [ $COUNTER lt 5 ]; do
echo "counter = " $COUNTER
let COUNTER=COUNTER+1
done
while2.sh
[root@localhost ~]$ vi while2.sh
#!/bin/bash
COUNTER=5
until [ $COUNTER lt 0 ]; do
echo "counter = " $COUNTER
let COUNTER=COUNTER1
done
[root@localhost ~]# vi tambah_user.sh
#!/bin/bash
jumlah=`wc l user.db | awk '{print $1}'`
for ((i=1;i<=jumlah;i++)); do
user=`head $i user.db | tail 1 | awk '{print $1}'`
pass=`head $i user.db | tail 1 | awk '{print $2}'`
useradd $user
echo "$pass" | passwd stdin $user
done
membuat database
[root@localhost ~]# vi user.db
bea bea123
ukie ukie123
Execute file :
[root@localhost ~]# ./tambah_user.sh
atau
[root@localhost ~]# sh tambah_user.sh
Xinetd
Tool xinetd berfungsi untuk mengumpulkan service berbagai aplikasi menjadi satu daemon/engine,
biasanya yang tidak memiliki service / daemon sendiri.
Contoh, ftp server (tftp)
[root@server ~]# vim /var/lib/tftpboot/test.txt
[root@server ~]# systemctl stop tftp.service
tftp> quit
cat test
Backup
2. type
3. CD/DVD
2. proses burning
[root@localhost ~]# cdrecord
contoh:
# Membuat folder mounting iso dan folder link backup
[root@localhost ~]# mkdir /mnt/iso /mnt/burn
# Link folder /etc yang akan dibackup
[root@localhost ~]# ln s /etc /mnt/burn
# Link folder /home
[root@localhost ~]# ln s /home /mnt/burn
# Membuat file iso
[root@localhost ~]# mkisofs f r J o /mnt/backup.iso /mnt/burn
Catatan: kalo sudah pernah mengaktifkan teamviewer, silakan remove terlebih dahulu
directory /home/'user'/.local/share/teamviewer*. Kemudian ulangi kembali.
# Cek hasil backup dengan melakukan proses mounting iso terlebih
dahulu
[root@localhost ~]# mount /mnt/backup.iso /mnt/iso o loop
# Melihat hasil mounting/backup
[root@localhost ~]# ls /mnt/iso
contoh;
[root@localhost ~]# mkdir /home/nfs
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfsserver
Host A
[root@localhost ~]# vi /usr/bin/backup.sh
#!/bin/sh
####################################
#
# Backup to NFS mount script.
#
####################################
# What to backup.
backup_files="/etc "
# Where to backup to.
dest="/mnt/backup"
# Create archive filename.
day=$(date +%F)
hostname=$(hostname s)
archive_file="$hostname$day.tgz"
# Print start status message.
echo "Backing up $backup_files to $dest/$archive_file"
date
echo
# Backup the files using tar.
tar czf $dest/$archive_file $backup_files
# Print end status message.
echo
echo "Backup finished"
date
# Long listing of files in $dest to check file sizes.
ls lh $dest
# Menseting permission file backup.sh
[root@localhost ~]# chmod u+x /usr/bin/backup.sh
# Mounting NFS Client (A)
[root@localhost ~]# mount 192.168.5.245:/home/nfs /mnt/backup
# Menjalankan script backup.sh
[root@localhost ~]# ./backup.sh
simpan script backup.sh di crontab (schedulling)
Host B (192.168.5.245)
[root@localhost ~]# yum install nfsutils
[root@localhost ~]# vi /etc/exports
/home/nfs 192.168.5.244(rw,sync,no_root_squash,no_all_squash)
Host A (192.168.5.244)
[root@localhost ~]# vi /usr/bin/backupnew.sh
#!/bin/sh
#####################################
# Backup to NFS mount script.
#####################################
# Make Folder
dirA="burn"
dirB="nfs"
dir_backup1="/etc"
dir_backup2="/home"
nfs_server="192.168.5.245"
# Link Folder
mkdir /mnt/$dirA /mnt/$dirB
ln s $dir_backup1 /mnt/$dirA
ln s $dir_backup2 /mnt/$dirA
# Mount folder NFS
mount $nfs_server:/home/nfs /mnt/$dirB
# Create foldername.
waktu=$(date +%T)
hostname=$(hostname s)
folder_name="$hostname$waktu.iso"
# Make ISO file
mkisofs f r J o /mnt/$dirB/backup$folder_name /mnt/$dirA
# Print end status message.
echo
echo "Backup finished"
date
# Menseting permission file backup.sh
[root@localhost ~]# chmod u+x /usr/bin/backupnew.sh
# Menjalankan script backup.sh
[root@localhost ~]# backupnew.sh
simpan script backup.sh di crontab (schedulling)
# Menseting permission file backup.sh
[root@localhost ~]# chmod u+x /usr/bin/backupnew.sh
# Menjalankan script backup.sh
[root@localhost ~]# backupnew.sh
simpan script backup.sh di crontab (schedulling)
# membuat folder
[root@backup ~]# mkdir /home/backup
# Service rsyncd
[root@backup ~]# systemctl start rsyncd
[root@backup ~]# systemctl enable rsyncd
3. Setelah itu lakukan Execute rsync pada server Production (Source Host) seperti dibawah ini:
[root@pro ~]# rsync avz delete exclude
from=/etc/rsync_exclude.lst /root/work
192.168.5.245::backup
# Add in cron if you'd like to run reguraly
[root@pro ~]# crontab e
# for example, run at 2:00 AM in a day
00 02 * * * rsync avz delete exclude
from=/etc/rsync_exclude.lst /root/work/
192.168.5.245::backup
Crontab
Crontab adalah aplikasi scheduller berbentuk table
[root@localhost ~]#
Menjalankan crontab
[root@localhost ~]# crontab e
Menseting crontab:
0 22 * * * /usr/bin/backup.sh
[root@localhost ~]# systemctl listunitfiles
UNIT FILE STATE
procsysfsbinfmt_misc.automount static
devhugepages.mount static
devmqueue.mount static
procfsnfsd.mount static
procsysfsbinfmt_misc.mount static
sysfsfuseconnections.mount static
syskernelconfig.mount static
syskerneldebug.mount static
tmp.mount disabled
varlibnfsrpc_pipefs.mount static
brandbot.path disabled
cups.path enabled
systemdaskpasswordconsole.path static
Partisi Hardisk
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2550 2805 2048000 82 Linux swap / Solaris
/dev/sda3 2805 7905 40960000 83 Linux
keterangan :
+ Disk /dev/sda
+ besar hardisk : 80.0 GB
+ umlah partisi : 3 (sda1, sda2, sda3)
UUID=a9f5ac03 / ext4 defaults 1 1
UUID=6266e184 /home ext4 defaults 1 2
UUID=dc975e4d swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
keterangan:
fs_specs fs_fde fs_vfstype fs_mntops fs_freq fspassno
[root@localhost ~]# fdisk /dev/sda
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b53b4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2550 2805 2048000 82 Linux swap /
Solaris
/dev/sda3 2805 7905 40960000 83 Linux
Command action
e extended
p primary partition (14)
e
Selected partition 4
First cylinder (79059729, default 7905):
Using default value 7905
Last cylinder, +cylinders or +size{K,M,G} (79059729, default 9729):
Using default value 9729
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b53b4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2550 2805 2048000 82 Linux swap /
Solaris
/dev/sda3 2805 7905 40960000 83 Linux
/dev/sda4 7905 9729 14659168+ 5 Extended
Command (m for help): n
First cylinder (79059729, default 7905):
Using default value 7905
Last cylinder, +cylinders or +size{K,M,G} (79059729, default 9729):
10G
Value out of range.
Last cylinder, +cylinders or +size{K,M,G} (79059729, default 9729):
+10G
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes/ro
Disk identifier: 0x000b53b4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2550 2805 2048000 82 Linux swap /
Solaris
/dev/sda3 2805 7905 40960000 83 Linux
/dev/sda4 7905 9729 14659168+ 5 Extended
/dev/sda5 7905 9210 10490269+ 83 Linux
Hex code (type L to list codes): L
Hex code (type L to list codes): 7
Changed system type of partition 5 to 7 (HPFS/NTFS)
Command (m for help): p
Disk /dev/sda: 80.0 GB, 80025280000 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b53b4
Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20480000 83 Linux
/dev/sda2 2550 2805 2048000 82 Linux swap /
Solaris
/dev/sda3 2805 7905 40960000 83 Linux
/dev/sda4 7905 9729 14659168+ 5 Extended
/dev/sda5 7905 9210 10490269+ 7 HPFS/NTFS
Command (m for help): w
The partition table has been altered!
Calling ioctl() to reread partition table.
WARNING: Rereading the partition table failed with error 16: Device
or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]# reboot
Konfigurasi :
1. Mengaktifkan option quota dengan menambahkan usrquota,grpquota di file /etc/fstab
[root@localhost ~]# vim /etc/fstab
UUID=6266e184 /home ext4 defaults,usrquota,grpquota 1 2
keterangan, menambahkan option "usrquota,grpquota"
[root@localhost ~]# mount o remount /home
3. membuat quota
[root@localhost ~]# setquota a student 100000 100000 100000 100000
keterangan kapasitas 100 Megabyte (hard soft) batas inode inode di
hardisk
[root@localhost ~]# repquota a
Compilie Kernel
Kernel merupakan core dari sistem operasi
di dalam sebuah sistem operasi sendiri mempunyai 2 tipe kernel, yaitu :
1. Monolitik
contoh, linux,mac
keuntungan lebih stabil
kerugian, untuk instalasi lebih sulit
2. Modular
contoh, windows
Keuntungan lebih mudah instalasi
Kerugian, cendrung tidak stabil
Pada saat melakukan compile kernel kita akan diminta untuk melakukan beberapa pilihan
modul/driver yang dimiliki oleh kernel tersebut, dimana pilihan tersebut berupa:
Y[*] monolitik
M[*] modular
N[ ] none, tidak dipilih (default)
linux module = driver hardware
semakin banyak yang diminta untuk masing-masing kernel semakin lama proses Compile
perhatikan dari pilihan kernel (make menuconfig) untuk processor (biasanya monolitik) dan
network bersifat modular
[root@localhost ~]# yum enablerepo=elrepokernel install kernelml
autoconf
automake
bc
bison
byacc
flex
gcc
gcc-c++
gettext
libpciaccess
libpciaccess-devel (this by default is not installed)
libstdc++ (for x86_64 systems)
libtool
make
ncurses-devel
patch
rpm-build
man
[root@localhost ~]# yum install autoconf automake bc bison byacc flex gcc gcc-c++ gettext
libpciaccess libpciaccess-devel libstdc++ libtool make ncurses-devel patch rpm-build man ncurses
ncurses-devel libelf-devel or elfutils-libelf-devel openssl openssl-devel
[root@localhost ~]# yum update -y
Unpack(ekstrak):
[root@localhost ~]# tar xf linux3.18.4.tar.xz C /usr/src/
Masuk ke direktory ekstraks:
[root@localhost ~]# cd /usr/src/linux3.18.4
Lakukan Configure :
[root@localhost linux3.18.4]# make menuconfig
Disini kita bisa memilih kebutuhan device modul atau driver hardware
kita:
Contoh:
Device Drivers > Network device support > Ethernet (10000 Mbit)
Intel(R) 10GbE PCI Express adapters support
atau secara default saja.
*Save the new kernel configuration
[root@localhost linux3.18.4]# make oldconfig
Compile :
[root@localhost linux3.18.4]# make
Installing ke dalam system :
[root@localhost linux3.18.4]# make modules_install install
Reboot system :
[root@localhost linux3.18.4]# reboot
catatan:
http://linoxide.com/linux-how-to/upgrade-linux-kernel-stable-3-18-4-centos/
Networking
Untuk mengecek informasi jaringan bisa menggunakan ipcalc
[root@localhost ~]# yum install ipcalc
[root@localhost ~]$ ipcalc 192.168.5.0/24
Wakeonlan
Untuk server yang dijadikan target lakukan seting terlebih dahulu seperti dibawah ini:
[root@localhost ~]# yum y install ethtool
[root@localhost ~]# ethtool s enp2s0 wol g
[root@localhost ~]# vi /etc/sysconfig/networkscripts/ifcfgenp2s0
# tambahkan pada akhir baris
ETHTOOL_OPTS="wol g"
#Coba cek MACADDRESS:
[root@localhost ~]# ifconfig enp2s0 | grep ether | awk '{print $2}'
1c:1b:0d:06:e1:6f
#Shutdown
[root@localhost ~]# shutdown h now
[root@localhost ~]# yum y install nettools
[root@localhost ~]# etherwake i enp2s0 1b:0d:06:e1:6f
atau
[root@localhost ~]# rpm Uvh wol0.7.14.el7.x86_64.rpm
[root@localhost ~]# wol 1c:1b:0d:06:e1:6f
# set hostname
[root@localhost ~]# hostnamectl sethostname cherly.com
# display devices
[root@cherly ~]# nmcli d
DEVICE TYPE STATE CONNECTION
enp2s0 ethernet connected enp2s0
lo loopback unmanaged
# set IPv4 address ⇒ nmcli *** [IP address]
[root@cherly ~]# nmcli c modify enp2s0 ipv4.addresses 192.168.6.245/24
# set default gateway
[root@cherly ~]# nmcli c modify enp2s0 ipv4.gateway 192.168.6.1
# set DNS
[root@cherly ~]# nmcli c modify enp2s0 ipv4.dns 192.168.6.1
# set manual for static setting (it's "auto" for DHCP)
[root@cherly ~]# nmcli c modify enp2s0 ipv4.method manual
# restart the interface and reload the settings
[root@cherly ~]# nmcli c down enp2s0; nmcli c up enp2s0