SlideShare a Scribd company logo
© 2014 IBM Corporation
IBMID Linux
POT/POC Survival Guide
Nugroho Gito
Software Client Architect
ngito@id.ibm.com
2
Document Version
Version Date Author Description
0.1 2015-12-20 Nugroho Gito Initial Version
13 April 2017
3
Agenda
1. Background
2. Pre Requisites
3. Working in Shell
1. UNIX Input/Output Streams
2. Environment variables
3. Regular Expression
4. Text Processing
5. VIM
6. Intro to Shell Scripting
4. Storage
1. Disk, Partition, File System Concept
2. Logical Volume Manager Concept
3. Disk, Partition Commands – Without LVM
4. Disk, Partition Commands – With LVM (GUI
& CLI)
5. Cheat Sheets
1. Global Configuration File
2. Adding disk without restart
3. Creating Offline yum Repository
4. Resolving Dependency Quickly with rpm
5. How to keep IP Address unchanged after
copying VM
6. Configure X Server
7. Passwordless ssh/sftp
8. Configure yum from IBM FTP
6. VMWare Networking
1. NAT
2. Bridge
3. Host-Only
7. VMWare Tools
1. Shared Folder
2. CD/DVD Emulation
8. VMWare vCenter Converter
13 April 2017
4
1. Background
13 April 2017
5
1. Background
 Basic survival guide and cheat sheets on Linux
 How to survive POC / POT
 Work efficiently in Linux/UNIX environment
 Most of the commands here can work in Linux/UNIX
 Most UNIX commercial distributions inherited from AT&T System V, therefore by default it
will not come with GNU based utilities.
Some commands can only work on GNU based utilities (eg: gawk, vim)
 Basic Text Processing in Linux/UNIX
13 April 2017
6
2. Pre Requisites
13 April 2017
7
2. Pre Requisites
 This work for Red Hat based distributions including:
– Red Hat Enterprise Linux
– CentOS
– Fedora
 Linux ISO files
Having Linux ISO files proves to be very handy, so please get ISO files from:
https://ftp3.linux.ibm.com/
(Requires manager’s approval)
 How to know my Linux version?
cat /etc/redhat-release
 Hypervisor: VMWare Workstation
Get VMWare License from here:
https://nasoftware.ibm.com/sales/ctp.nsf/doc/MODM-7BQT8L?OpenDocument
(Requires manager’s approval)
13 April 2017
8
3. Working in Shell
Make friend with bash or ksh!
13 April 2017
9
3. Working in Shell
13 April 2017
 Most Linux distributions uses bash, however key navigation in bash is slightly different with
ksh (Korn Shell) which uses vi key binding
 The advantage of using vi key binding, it uses the same vi navigation key, and it provides
more advanced command line editing
 From this onward, we will turn on vi key binding by using following command:
10
3. Working in Shell
set –o vi # We can put this in $HOME/.bashrc to automatically executed after user login
http://www.catonmat.net/download/bash-vi-editing-mode-cheat-sheet.pdf
13 April 2017
11
3.1. UNIX Input/Output Streams (IMPORTANT!)
13 April 2017
Standard Streams Pipeline Processing
I/O Redirections
12
3.1. UNIX Input/Output Streams Sample
13 April 2017
Command Description
db2 << EOF 2>&1 > db2.out
get db cfg
get dbm cfg
list db directory
connect to LDAPDB2B
list tables
EOF
1. Execute db2 command
2. Redirect all input, delimited by string EOF
3. Redirect stderr (2) (2>&1) to stdout (1)
4. Redirect stdout to db2.out file
5. db2 command will execute all lines in red
find / -type f -ls | sort -rnk 7 | head -n 10 1. List all files from / directory
2. Sort output reverse order (highest to lowest)
based on column 7 (file size)
3. Limit output to 10 rows only
find / -name *.txt | xargs grep –i text
find / -name “*.txt” | xargs grep –i text
1. List all txt files from / directory
2. Find text ignore case in each txt files
13
3.2. Shell Environment Variables (IMPORTANT!)
Variable Description
DISPLAY Contains the identifier for the display that X11 programs should use by default.
HOME Indicates the home directory of the current user: the default argument for the cd built-in command.
IFS Indicates the Internal Field Separator that is used by the parser for word splitting after expansion.
LANG
LANG expands to the default system locale; LC_ALL can be used to override this. For example, if its
value is pt_BR, then the language is set to (Brazilian) Portuguese and the locale to Brazil.
LD_LIBRARY_PATH
On many Unix systems with a dynamic linker, contains a colon-separated list of directories that the
dynamic linker should search for shared objects when building a process image after exec, before
searching in any other directories.
PATH
Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for
commands.
PWD Indicates the current working directory as set by the cd command.
RANDOM Generates a random integer between 0 and 32,767 each time it is referenced.
SHLVL
Increments by one each time an instance of bash is started. This variable is useful for determining
whether the built-in exit command ends the current session.
TERM Refers to the display type
TZ Refers to Time zone. It can take values like GMT, AST, etc.
UID Expands to the numeric user ID of the current user, initialized at shell startup.
13 April 2017
http://www.tutorialspoint.com/unix/unix-environment.htm
14
3.3. Regular Expression
 TODO
13 April 2017
15
3.4. Text Processing
13 April 2017
No Command Description Samples
1 cat concatenate files and print on the standard output
2 wc print newline, word, and byte counts for each file
3 grep print lines matching a pattern
4 head output the first part of files
5 tail output the last part of files
6 awk pattern scanning and processing language
7 sed stream editor for filtering and transforming text
8 tr translate or delete characters
9 cut remove sections from each line of files
10 paste merge lines of files
11 colrm remove columns from a file
12 expand convert tabs to spaces
13 unexpand convert spaces to tabs
14 diff compare files line by line
15 comm
16 cmp compare two files byte by byte
17 fold wrap each input line to fit in specified width
18 bc
19 split split a file into pieces
20 uniq report or omit repeated lines
21 sort sort lines of text files
22 join join lines of two files on a common field
http://www.ibm.com/developerworks/aix/library/au-unixtext/
http://www.ibm.com/developerworks/aix/library/au-textprocess.html
16
3.5. VIM
13 April 2017
17
3.6. Intro to Shell Scripting
 Looping (for)
for file in `ls /etc/`; do
echo $file
done
 Looping (while)
ls /etc/ | while read file; do
echo $file
done
 Math expression
13 April 2017
18
4. Storage
Disk, Partition, File System & LVM
13 April 2017
19
4.1. Disk, Partition, File System Concept
13 April 2017
20
4.2. Disk, Partition Commands – Without LVM
fdisk /dev/sdb # create new partition: press n (new
# partition), accept all default settings
# to create partition on all usable disk,
# press w (write partition)
mkfs.ext4 /dev/sdb1 # format new partition
blkid /dev/sdb1 # write down new partition uuid (optional)
vi /etc/fstab # Add new entry to /etc/fstab
mount /opt # mount partition, make it readable/writable to OS
df -h # new partition should appear
ls -la /dev/disk/by-uuid # to see all UUID for each partition (optional)
13 April 2017
21
4.3. Logical Volume Manager - Concept
13 April 2017
User Interface Command
CLI lvm
GUI system-config-lvm
22
4.3. Disk, Partition Commands – With LVM (CLI)
Scenario:
1. Create new volume group (vgtest) from two unformatted disk (sdd & sde)
2. Create new logical volume
3. Format newly created logical volume
4. Mount logical volume
(root)/root>fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 652 5237158+ 83 Linux
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 652 5237158+ 83 Linux
Disk /dev/sdd: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
(root)/root>pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created
(root)/root>pvcreate /dev/sde
Physical volume "/dev/sde" successfully created
(root)/root>vgcreate vgtest /dev/sdd /dev/sde
/dev/hdc: open failed: No medium found
Volume group "vgtest" successfully created
(root)/root>lvcreate -L 500M -n lvol0 vgtest
/dev/hdc: open failed: No medium found
Logical volume "lvol0" created
(root)/root>mkfs -t ext3 -m 1 -v /dev/vgtest/lvol0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
128016 inodes, 512000 blocks
5120 blocks (1.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
(root)/root>mkdir /mnt/vfs
(root)/root>mount -t ext3 /dev/vgtest/lvol0 /mnt/vfs
(root)/root>cd /mnt/vfs
(root)/mnt/vfs>df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgtest-lvol0
485M 11M 469M 3% /mnt/vfs
13 April 2017
23
4.4. Disk, Partition Commands – With LVM (GUI)
Scenario:
1. Make sure X Window Manager already installed
2. Run system-config-lvm
3. Initialize Entries
4. Create Volume Group
5. Add Physical Volume
6. Create Logical Volume, set LV Size, File System & Mount Point
13 April 2017
24
5. Cheat Sheets
Shortcuts that can save you hours of manual work
13 April 2017
25
5.1. Global Configuration File (IMPORTANT!)
13 April 2017
No File Name Description
1 /etc/bashrc Global BASH startup scripts
2 /etc/profile Global environment variable
3 /etc/inittab Controls how Linux start (3:text mode multi user, 5:X11)
4 /etc/fstab Controls which file system automatically mounted during startup
5 /etc/kde/kdm/kdmrc Controls how KDE start X server
6 /etc/gdm/custom.cnf Controls how GNOME starts X server, to enable X listening to TCP port, add
DisallowTCP=false under [security]
7 /etc/profile.d/ Global application environment setup
8 /etc/network/interfaces List of network interfaces
9 /etc/xinetd.conf Replacement of UNIX inetd.conf which refers to files unde /etc/xinetd.d
10 /etc/hosts.allow Lists of allowed host (tcp wrapper)
11 /etc/hosts.deny Lists of denied host (tcp wrapper)
12 /etc/redhat-release Release version
13 /etc/sysctl.conf Kernel settings
14 /etc/security/limits.conf Shell limits per user
15 /etc/udev/rules.d/70-persistent-net.rules Mapping between MAC address with ethernet devices (ethX)
16 /etc/sysconfig/network-scripts/ifcfg-ethX IP Address/Network Mask/Gateway settings
17 /etc/resolv.conf DNS Settings (DHCP)
18 /etc/selinux/config SE Linux config
19 /etc/hosts Host Name mapping between IP Address to Host Name or FQDN
20 /proc/meminfo Memory info, MemTotal & SwapTotal
21 /proc/cpuinfo Processor info, MemTotal & SwapTotal
Background
• Sometimes config require changes but have no clue where its location?
26
5.2. Adding Disk without Restart
13 April 2017
Background
• Running out of disk while installing some software? Follow this command to quickly expand
your file system
# How to add new disk to RHEL, and force to rescan without reboot
for i in `ls /sys/class/scsi_host`; do
echo "- - -" > /sys/class/scsi_host/$i/scan
fdisk -l
tail -f /var/log/message
done
# The rest of command includes creating new file system / increase
# existing file system
27
Background
• When installing some software, it requires dependency to Linux package, and installing
with rpm will drive you crazy? Use offline yum repo, to install Linux package with yum with
auto dependency resolution.
# Steps
# 1. Insert 1st DVD into DVD ROM
# 2. Assuming CD/DVD ROM mount point is at /mnt/cdrom
# Manually configuring CD/DVD mount
# Modify /etc/fstab, add this:
# /dev/cdrom /mnt/cdrom iso9660 ro,user,noauto,unhide
# mkdir /mnt/cdrom
# mount /mnt/cdrom
# vi /etc/yum.repos.d/local.repo
# Add the following details.
[LocalRepo]
name=Local Repository
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
yum clean all
5.3. Creating Offline yum Repository
13 April 2017
28
5.4. Resolving Dependency Quickly with rpm
13 April 2017
Background
• TODO
29
5.5. How to keep IP Address unchanged after copying VM
13 April 2017
Background
• After copying VM and after boot you got this message "device eth0 does not seem to be
present, delaying initialization“, and VM can’t get any IP Address/IP Address got changed.
• Edit: /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1",
KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1",
KERNEL=="eth*", NAME="eth1"
• Delete the first SUBSYSTEM entry in the file.
• Update the 'eth1' attribute in the remaining entry to 'eth0'
• Edit /etc/sysconfig/network-scripts/ifcfg-eth0
• Change the HWADDR to match the new mac address listed in the newly edited 70-
persistent-net.rules file.
• reboot.
30
Background
• Sometimes you need to kick off GUI program running on Linux/UNIX Host
• If you don’t have physical access to Host Console, and only remote access is available
(telnet/ssh)
5.6. Configure X Server
13 April 2017
31
5.7. Passwordless ssh/sftp
Background
Sometimes you frequently login to a server and you want to run unattended script from
remote.
Steps
1. ssh-copy-id user@host # It will prompt your password at remote host
2. ssh user@host # It won’t ask for password
3. sftp user@host # It won’t ask for password
13 April 2017
32
5.8. Configure yum from IBM FTP
Background
RHEL yum will not work without registered RHEL accounts. For IBMers this steps will
configure yum to work with IBM FTP.
Steps
wget -qO- --no-check-certificate https://rhn.linux.ibm.com/pub/bootstrap/bootstrap.sh | /bin/bash
rhnreg_ks --force --username=user@<cc>.ibm.com --password=your_ftp3_passwd
or
rhn_register
13 April 2017

More Related Content

What's hot

WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
James Bayer
 
Achieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAAchieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAA
Markus Michalewicz
 
VMworld 2017 - Top 10 things to know about vSAN
VMworld 2017 - Top 10 things to know about vSANVMworld 2017 - Top 10 things to know about vSAN
VMworld 2017 - Top 10 things to know about vSAN
Duncan Epping
 
Synology product training - DSM introduction
Synology product training - DSM introductionSynology product training - DSM introduction
Synology product training - DSM introductionWayne An
 
ELC21: VM-to-VM Communication Mechanisms for Embedded
ELC21: VM-to-VM Communication Mechanisms for EmbeddedELC21: VM-to-VM Communication Mechanisms for Embedded
ELC21: VM-to-VM Communication Mechanisms for Embedded
Stefano Stabellini
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
Brendan Gregg
 
10 Key Considerations For Selecting Hyper-Converged Infrastructure
10 Key Considerations For Selecting Hyper-Converged Infrastructure10 Key Considerations For Selecting Hyper-Converged Infrastructure
10 Key Considerations For Selecting Hyper-Converged Infrastructure
Heather Salmons Newswanger
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
Anu Chaudhry
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
Boden Russell
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
Thomas Rausch
 
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Sandesh Rao
 
Liquibase
LiquibaseLiquibase
Liquibase
Sergii Fesenko
 
Ex200
Ex200Ex200
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
Project ACRN
 
Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2
Gang He
 
MySQL_MariaDB로의_전환_기술요소-202212.pptx
MySQL_MariaDB로의_전환_기술요소-202212.pptxMySQL_MariaDB로의_전환_기술요소-202212.pptx
MySQL_MariaDB로의_전환_기술요소-202212.pptx
NeoClova
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
Harish1983
 
BKK16-208 EAS
BKK16-208 EASBKK16-208 EAS
BKK16-208 EAS
Linaro
 
QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
Pradeep Kumar
 
Linux Server vs Windows Server
Linux Server vs Windows ServerLinux Server vs Windows Server
Linux Server vs Windows Server
KongChunLeong1
 

What's hot (20)

WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
 
Achieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAAchieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAA
 
VMworld 2017 - Top 10 things to know about vSAN
VMworld 2017 - Top 10 things to know about vSANVMworld 2017 - Top 10 things to know about vSAN
VMworld 2017 - Top 10 things to know about vSAN
 
Synology product training - DSM introduction
Synology product training - DSM introductionSynology product training - DSM introduction
Synology product training - DSM introduction
 
ELC21: VM-to-VM Communication Mechanisms for Embedded
ELC21: VM-to-VM Communication Mechanisms for EmbeddedELC21: VM-to-VM Communication Mechanisms for Embedded
ELC21: VM-to-VM Communication Mechanisms for Embedded
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
10 Key Considerations For Selecting Hyper-Converged Infrastructure
10 Key Considerations For Selecting Hyper-Converged Infrastructure10 Key Considerations For Selecting Hyper-Converged Infrastructure
10 Key Considerations For Selecting Hyper-Converged Infrastructure
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
Oracle Real Application Clusters 19c- Best Practices and Internals- EMEA Tour...
 
Liquibase
LiquibaseLiquibase
Liquibase
 
Ex200
Ex200Ex200
Ex200
 
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introductionACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
 
Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2Comparison between OCFS2 and GFS2
Comparison between OCFS2 and GFS2
 
MySQL_MariaDB로의_전환_기술요소-202212.pptx
MySQL_MariaDB로의_전환_기술요소-202212.pptxMySQL_MariaDB로의_전환_기술요소-202212.pptx
MySQL_MariaDB로의_전환_기술요소-202212.pptx
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
BKK16-208 EAS
BKK16-208 EASBKK16-208 EAS
BKK16-208 EAS
 
QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?QEMU Disk IO Which performs Better: Native or threads?
QEMU Disk IO Which performs Better: Native or threads?
 
Linux Server vs Windows Server
Linux Server vs Windows ServerLinux Server vs Windows Server
Linux Server vs Windows Server
 

Similar to Linux Survival Kit for Proof of Concept & Proof of Technology

FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016
Muhammad Moinur Rahman
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layoutAcácio Oliveira
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
Acácio Oliveira
 
Lamp
LampLamp
LampReka
 
Lamp1
Lamp1Lamp1
Lamp1Reka
 
Linux basic
Linux basicLinux basic
Linux basic
Pragyagupta37
 
2.1 design hard disk layout v2
2.1 design hard disk layout v22.1 design hard disk layout v2
2.1 design hard disk layout v2
Acácio Oliveira
 
Devops for beginners
Devops for beginnersDevops for beginners
Devops for beginners
Vivek Parihar
 
Lamp ppt
Lamp pptLamp ppt
Lamp pptReka
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystemsAcácio Oliveira
 
linux installation.pdf
linux installation.pdflinux installation.pdf
linux installation.pdf
MuhammadShoaibHussai2
 
Edubooktraining
EdubooktrainingEdubooktraining
Edubooktraining
norhloudspeaker
 
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.comComandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
Wlademir RS
 

Similar to Linux Survival Kit for Proof of Concept & Proof of Technology (20)

FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
 
Lamp
LampLamp
Lamp
 
Lamp1
Lamp1Lamp1
Lamp1
 
Lamp1
Lamp1Lamp1
Lamp1
 
Linux basic
Linux basicLinux basic
Linux basic
 
2.1 design hard disk layout v2
2.1 design hard disk layout v22.1 design hard disk layout v2
2.1 design hard disk layout v2
 
Devops for beginners
Devops for beginnersDevops for beginners
Devops for beginners
 
Lamp ppt
Lamp pptLamp ppt
Lamp ppt
 
Unix 6 en
Unix 6 enUnix 6 en
Unix 6 en
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
 
linux installation.pdf
linux installation.pdflinux installation.pdf
linux installation.pdf
 
Edubooktraining
EdubooktrainingEdubooktraining
Edubooktraining
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.comComandos linux bash,  f2 linux pesquisa, http://f2linux.wordpress.com
Comandos linux bash, f2 linux pesquisa, http://f2linux.wordpress.com
 

More from Nugroho Gito

RHCSA EX200 - Summary
RHCSA EX200 - SummaryRHCSA EX200 - Summary
RHCSA EX200 - Summary
Nugroho Gito
 
Card payment evolution v1.0
Card payment evolution v1.0Card payment evolution v1.0
Card payment evolution v1.0
Nugroho Gito
 
IT Architect Profession
IT Architect ProfessionIT Architect Profession
IT Architect Profession
Nugroho Gito
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How To
Nugroho Gito
 
Mobile Enterprise Application Platform
Mobile Enterprise Application PlatformMobile Enterprise Application Platform
Mobile Enterprise Application Platform
Nugroho Gito
 
Ssh to Bluemix runtime container
Ssh to Bluemix runtime containerSsh to Bluemix runtime container
Ssh to Bluemix runtime container
Nugroho Gito
 
IBM Watson & Cognitive Computing - Tech In Asia 2016
IBM Watson & Cognitive Computing - Tech In Asia 2016IBM Watson & Cognitive Computing - Tech In Asia 2016
IBM Watson & Cognitive Computing - Tech In Asia 2016
Nugroho Gito
 
Parental Control, Internet Safety, Safe Internet for Children
Parental Control, Internet Safety, Safe Internet for ChildrenParental Control, Internet Safety, Safe Internet for Children
Parental Control, Internet Safety, Safe Internet for Children
Nugroho Gito
 

More from Nugroho Gito (8)

RHCSA EX200 - Summary
RHCSA EX200 - SummaryRHCSA EX200 - Summary
RHCSA EX200 - Summary
 
Card payment evolution v1.0
Card payment evolution v1.0Card payment evolution v1.0
Card payment evolution v1.0
 
IT Architect Profession
IT Architect ProfessionIT Architect Profession
IT Architect Profession
 
Ethereum Mining How To
Ethereum Mining How ToEthereum Mining How To
Ethereum Mining How To
 
Mobile Enterprise Application Platform
Mobile Enterprise Application PlatformMobile Enterprise Application Platform
Mobile Enterprise Application Platform
 
Ssh to Bluemix runtime container
Ssh to Bluemix runtime containerSsh to Bluemix runtime container
Ssh to Bluemix runtime container
 
IBM Watson & Cognitive Computing - Tech In Asia 2016
IBM Watson & Cognitive Computing - Tech In Asia 2016IBM Watson & Cognitive Computing - Tech In Asia 2016
IBM Watson & Cognitive Computing - Tech In Asia 2016
 
Parental Control, Internet Safety, Safe Internet for Children
Parental Control, Internet Safety, Safe Internet for ChildrenParental Control, Internet Safety, Safe Internet for Children
Parental Control, Internet Safety, Safe Internet for Children
 

Recently uploaded

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 

Recently uploaded (20)

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 

Linux Survival Kit for Proof of Concept & Proof of Technology

  • 1. © 2014 IBM Corporation IBMID Linux POT/POC Survival Guide Nugroho Gito Software Client Architect ngito@id.ibm.com
  • 2. 2 Document Version Version Date Author Description 0.1 2015-12-20 Nugroho Gito Initial Version 13 April 2017
  • 3. 3 Agenda 1. Background 2. Pre Requisites 3. Working in Shell 1. UNIX Input/Output Streams 2. Environment variables 3. Regular Expression 4. Text Processing 5. VIM 6. Intro to Shell Scripting 4. Storage 1. Disk, Partition, File System Concept 2. Logical Volume Manager Concept 3. Disk, Partition Commands – Without LVM 4. Disk, Partition Commands – With LVM (GUI & CLI) 5. Cheat Sheets 1. Global Configuration File 2. Adding disk without restart 3. Creating Offline yum Repository 4. Resolving Dependency Quickly with rpm 5. How to keep IP Address unchanged after copying VM 6. Configure X Server 7. Passwordless ssh/sftp 8. Configure yum from IBM FTP 6. VMWare Networking 1. NAT 2. Bridge 3. Host-Only 7. VMWare Tools 1. Shared Folder 2. CD/DVD Emulation 8. VMWare vCenter Converter 13 April 2017
  • 5. 5 1. Background  Basic survival guide and cheat sheets on Linux  How to survive POC / POT  Work efficiently in Linux/UNIX environment  Most of the commands here can work in Linux/UNIX  Most UNIX commercial distributions inherited from AT&T System V, therefore by default it will not come with GNU based utilities. Some commands can only work on GNU based utilities (eg: gawk, vim)  Basic Text Processing in Linux/UNIX 13 April 2017
  • 7. 7 2. Pre Requisites  This work for Red Hat based distributions including: – Red Hat Enterprise Linux – CentOS – Fedora  Linux ISO files Having Linux ISO files proves to be very handy, so please get ISO files from: https://ftp3.linux.ibm.com/ (Requires manager’s approval)  How to know my Linux version? cat /etc/redhat-release  Hypervisor: VMWare Workstation Get VMWare License from here: https://nasoftware.ibm.com/sales/ctp.nsf/doc/MODM-7BQT8L?OpenDocument (Requires manager’s approval) 13 April 2017
  • 8. 8 3. Working in Shell Make friend with bash or ksh! 13 April 2017
  • 9. 9 3. Working in Shell 13 April 2017  Most Linux distributions uses bash, however key navigation in bash is slightly different with ksh (Korn Shell) which uses vi key binding  The advantage of using vi key binding, it uses the same vi navigation key, and it provides more advanced command line editing  From this onward, we will turn on vi key binding by using following command:
  • 10. 10 3. Working in Shell set –o vi # We can put this in $HOME/.bashrc to automatically executed after user login http://www.catonmat.net/download/bash-vi-editing-mode-cheat-sheet.pdf 13 April 2017
  • 11. 11 3.1. UNIX Input/Output Streams (IMPORTANT!) 13 April 2017 Standard Streams Pipeline Processing I/O Redirections
  • 12. 12 3.1. UNIX Input/Output Streams Sample 13 April 2017 Command Description db2 << EOF 2>&1 > db2.out get db cfg get dbm cfg list db directory connect to LDAPDB2B list tables EOF 1. Execute db2 command 2. Redirect all input, delimited by string EOF 3. Redirect stderr (2) (2>&1) to stdout (1) 4. Redirect stdout to db2.out file 5. db2 command will execute all lines in red find / -type f -ls | sort -rnk 7 | head -n 10 1. List all files from / directory 2. Sort output reverse order (highest to lowest) based on column 7 (file size) 3. Limit output to 10 rows only find / -name *.txt | xargs grep –i text find / -name “*.txt” | xargs grep –i text 1. List all txt files from / directory 2. Find text ignore case in each txt files
  • 13. 13 3.2. Shell Environment Variables (IMPORTANT!) Variable Description DISPLAY Contains the identifier for the display that X11 programs should use by default. HOME Indicates the home directory of the current user: the default argument for the cd built-in command. IFS Indicates the Internal Field Separator that is used by the parser for word splitting after expansion. LANG LANG expands to the default system locale; LC_ALL can be used to override this. For example, if its value is pt_BR, then the language is set to (Brazilian) Portuguese and the locale to Brazil. LD_LIBRARY_PATH On many Unix systems with a dynamic linker, contains a colon-separated list of directories that the dynamic linker should search for shared objects when building a process image after exec, before searching in any other directories. PATH Indicates search path for commands. It is a colon-separated list of directories in which the shell looks for commands. PWD Indicates the current working directory as set by the cd command. RANDOM Generates a random integer between 0 and 32,767 each time it is referenced. SHLVL Increments by one each time an instance of bash is started. This variable is useful for determining whether the built-in exit command ends the current session. TERM Refers to the display type TZ Refers to Time zone. It can take values like GMT, AST, etc. UID Expands to the numeric user ID of the current user, initialized at shell startup. 13 April 2017 http://www.tutorialspoint.com/unix/unix-environment.htm
  • 14. 14 3.3. Regular Expression  TODO 13 April 2017
  • 15. 15 3.4. Text Processing 13 April 2017 No Command Description Samples 1 cat concatenate files and print on the standard output 2 wc print newline, word, and byte counts for each file 3 grep print lines matching a pattern 4 head output the first part of files 5 tail output the last part of files 6 awk pattern scanning and processing language 7 sed stream editor for filtering and transforming text 8 tr translate or delete characters 9 cut remove sections from each line of files 10 paste merge lines of files 11 colrm remove columns from a file 12 expand convert tabs to spaces 13 unexpand convert spaces to tabs 14 diff compare files line by line 15 comm 16 cmp compare two files byte by byte 17 fold wrap each input line to fit in specified width 18 bc 19 split split a file into pieces 20 uniq report or omit repeated lines 21 sort sort lines of text files 22 join join lines of two files on a common field http://www.ibm.com/developerworks/aix/library/au-unixtext/ http://www.ibm.com/developerworks/aix/library/au-textprocess.html
  • 17. 17 3.6. Intro to Shell Scripting  Looping (for) for file in `ls /etc/`; do echo $file done  Looping (while) ls /etc/ | while read file; do echo $file done  Math expression 13 April 2017
  • 18. 18 4. Storage Disk, Partition, File System & LVM 13 April 2017
  • 19. 19 4.1. Disk, Partition, File System Concept 13 April 2017
  • 20. 20 4.2. Disk, Partition Commands – Without LVM fdisk /dev/sdb # create new partition: press n (new # partition), accept all default settings # to create partition on all usable disk, # press w (write partition) mkfs.ext4 /dev/sdb1 # format new partition blkid /dev/sdb1 # write down new partition uuid (optional) vi /etc/fstab # Add new entry to /etc/fstab mount /opt # mount partition, make it readable/writable to OS df -h # new partition should appear ls -la /dev/disk/by-uuid # to see all UUID for each partition (optional) 13 April 2017
  • 21. 21 4.3. Logical Volume Manager - Concept 13 April 2017 User Interface Command CLI lvm GUI system-config-lvm
  • 22. 22 4.3. Disk, Partition Commands – With LVM (CLI) Scenario: 1. Create new volume group (vgtest) from two unformatted disk (sdd & sde) 2. Create new logical volume 3. Format newly created logical volume 4. Mount logical volume (root)/root>fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1305 10377990 8e Linux LVM Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 652 5237158+ 83 Linux Disk /dev/sdc: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 652 5237158+ 83 Linux Disk /dev/sdd: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdd doesn't contain a valid partition table Disk /dev/sde: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sde doesn't contain a valid partition table (root)/root>pvcreate /dev/sdd Physical volume "/dev/sdd" successfully created (root)/root>pvcreate /dev/sde Physical volume "/dev/sde" successfully created (root)/root>vgcreate vgtest /dev/sdd /dev/sde /dev/hdc: open failed: No medium found Volume group "vgtest" successfully created (root)/root>lvcreate -L 500M -n lvol0 vgtest /dev/hdc: open failed: No medium found Logical volume "lvol0" created (root)/root>mkfs -t ext3 -m 1 -v /dev/vgtest/lvol0 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 128016 inodes, 512000 blocks 5120 blocks (1.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 63 block groups 8192 blocks per group, 8192 fragments per group 2032 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 33 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. (root)/root>mkdir /mnt/vfs (root)/root>mount -t ext3 /dev/vgtest/lvol0 /mnt/vfs (root)/root>cd /mnt/vfs (root)/mnt/vfs>df -h . Filesystem Size Used Avail Use% Mounted on /dev/mapper/vgtest-lvol0 485M 11M 469M 3% /mnt/vfs 13 April 2017
  • 23. 23 4.4. Disk, Partition Commands – With LVM (GUI) Scenario: 1. Make sure X Window Manager already installed 2. Run system-config-lvm 3. Initialize Entries 4. Create Volume Group 5. Add Physical Volume 6. Create Logical Volume, set LV Size, File System & Mount Point 13 April 2017
  • 24. 24 5. Cheat Sheets Shortcuts that can save you hours of manual work 13 April 2017
  • 25. 25 5.1. Global Configuration File (IMPORTANT!) 13 April 2017 No File Name Description 1 /etc/bashrc Global BASH startup scripts 2 /etc/profile Global environment variable 3 /etc/inittab Controls how Linux start (3:text mode multi user, 5:X11) 4 /etc/fstab Controls which file system automatically mounted during startup 5 /etc/kde/kdm/kdmrc Controls how KDE start X server 6 /etc/gdm/custom.cnf Controls how GNOME starts X server, to enable X listening to TCP port, add DisallowTCP=false under [security] 7 /etc/profile.d/ Global application environment setup 8 /etc/network/interfaces List of network interfaces 9 /etc/xinetd.conf Replacement of UNIX inetd.conf which refers to files unde /etc/xinetd.d 10 /etc/hosts.allow Lists of allowed host (tcp wrapper) 11 /etc/hosts.deny Lists of denied host (tcp wrapper) 12 /etc/redhat-release Release version 13 /etc/sysctl.conf Kernel settings 14 /etc/security/limits.conf Shell limits per user 15 /etc/udev/rules.d/70-persistent-net.rules Mapping between MAC address with ethernet devices (ethX) 16 /etc/sysconfig/network-scripts/ifcfg-ethX IP Address/Network Mask/Gateway settings 17 /etc/resolv.conf DNS Settings (DHCP) 18 /etc/selinux/config SE Linux config 19 /etc/hosts Host Name mapping between IP Address to Host Name or FQDN 20 /proc/meminfo Memory info, MemTotal & SwapTotal 21 /proc/cpuinfo Processor info, MemTotal & SwapTotal Background • Sometimes config require changes but have no clue where its location?
  • 26. 26 5.2. Adding Disk without Restart 13 April 2017 Background • Running out of disk while installing some software? Follow this command to quickly expand your file system # How to add new disk to RHEL, and force to rescan without reboot for i in `ls /sys/class/scsi_host`; do echo "- - -" > /sys/class/scsi_host/$i/scan fdisk -l tail -f /var/log/message done # The rest of command includes creating new file system / increase # existing file system
  • 27. 27 Background • When installing some software, it requires dependency to Linux package, and installing with rpm will drive you crazy? Use offline yum repo, to install Linux package with yum with auto dependency resolution. # Steps # 1. Insert 1st DVD into DVD ROM # 2. Assuming CD/DVD ROM mount point is at /mnt/cdrom # Manually configuring CD/DVD mount # Modify /etc/fstab, add this: # /dev/cdrom /mnt/cdrom iso9660 ro,user,noauto,unhide # mkdir /mnt/cdrom # mount /mnt/cdrom # vi /etc/yum.repos.d/local.repo # Add the following details. [LocalRepo] name=Local Repository baseurl=file:///mnt/cdrom enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 yum clean all 5.3. Creating Offline yum Repository 13 April 2017
  • 28. 28 5.4. Resolving Dependency Quickly with rpm 13 April 2017 Background • TODO
  • 29. 29 5.5. How to keep IP Address unchanged after copying VM 13 April 2017 Background • After copying VM and after boot you got this message "device eth0 does not seem to be present, delaying initialization“, and VM can’t get any IP Address/IP Address got changed. • Edit: /etc/udev/rules.d/70-persistent-net.rules # This file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # You can modify it, as long as you keep each rule on a single # line, and change only the value of the NAME= key. # PCI device 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" # PCI device 0x15ad:0x07b0 (vmxnet3) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" • Delete the first SUBSYSTEM entry in the file. • Update the 'eth1' attribute in the remaining entry to 'eth0' • Edit /etc/sysconfig/network-scripts/ifcfg-eth0 • Change the HWADDR to match the new mac address listed in the newly edited 70- persistent-net.rules file. • reboot.
  • 30. 30 Background • Sometimes you need to kick off GUI program running on Linux/UNIX Host • If you don’t have physical access to Host Console, and only remote access is available (telnet/ssh) 5.6. Configure X Server 13 April 2017
  • 31. 31 5.7. Passwordless ssh/sftp Background Sometimes you frequently login to a server and you want to run unattended script from remote. Steps 1. ssh-copy-id user@host # It will prompt your password at remote host 2. ssh user@host # It won’t ask for password 3. sftp user@host # It won’t ask for password 13 April 2017
  • 32. 32 5.8. Configure yum from IBM FTP Background RHEL yum will not work without registered RHEL accounts. For IBMers this steps will configure yum to work with IBM FTP. Steps wget -qO- --no-check-certificate https://rhn.linux.ibm.com/pub/bootstrap/bootstrap.sh | /bin/bash rhnreg_ks --force --username=user@<cc>.ibm.com --password=your_ftp3_passwd or rhn_register 13 April 2017