Linux command for LPIC preparation

LPIC 1 Objectives
https://www.lpi.org/our-certifications/exam-101-objectives

UNIT 1
history -d 100
history -c = clears the history

Occasionally, the problem arises where you can’t remember the exact name of a command to look up
$ man -k “system information”
dumpe2fs (8) – dump ext2/ext3/ext4 filesystem information
uname (1) – print system information

Linux file descriptor:
Standard Input (STDIN) = 0  <, << Standard Output (STDOUT) = 1  >, >>
Standard Error (STDERR) = 2

echo $PATH 1> path.txt
echo $PATH > path.txt
A common trick is to redirect standard output or standard error to /dev/null. This file is a device that’s connected to nothing; it’s used when you want to get rid of data.
whine 2> /dev/null

date +%M

mkdir -p /home/yuko/a/b/c
mv -f /tmp/A/* /targetfolder

rm -Rf /tmp/A /*

cp -Rf /tmp/A/* /targetfolder
echo ‘$HOME’ = $HOME

echo “$HOME” = /home/yuko

echo `date +%M` = 50
lsattr filename

chattr +i filename

rm filename -> cant delete, even as root

chattr -i filename

rm filename -> ok

i = immutable
tar -cvf file.tar /tmp/file

tar -tvf file.tar

tar -xvf file.tar

Gzip -> z

bzip2 -> j
dd if=fd-image fo=/dev/fd0

if (input file), fo(file output)
>/dev/null 2>&1

標準出力&エラー出力:非表示
file1=abc; file2=def

tac file1 file2

: fedcba
ls | tee file.txt = ls & ls > file.txt

ls | tee -a file.txt = ls & ls >> file.txt

Tee command is used to store and view (both at the same time) the output of any other command.
grep

-v パターンに一致しない行を表示

-n 行番号を表示

-l パターンと一致するファイル名を表示

-i 大文字ー小文字を区別しない
head -3 file1

=display the first 3 row

tail -f -n 5 /var/log

=display the last 5 lines continuosly. ctrl+c to force quit
tr [a-z] [A-Z] Unix

tr \\r \\n unix.txt
Windows -> Unix

tr -d \\r unix.txt
Unix -> Windows

perl -p -e ‘s/\n/\r\n/’ windows.txt
:w!

:! ls -l
Display all process

= ps ax . pstree . ps -ef

Display process which show the NI value to indicate the priority

= ps -l atau top

semakin kecil nilai NI, makin tinggi prioritas si job tsb
nice and renice command

http://www.slashroot.in/nice-and-renice-command-usage-examples-process-priority-linux
renice can also be done by the command top; type r; input the PID of a process; then put the nice value
jobs

=display all the background and foreground running job.
SIGHUP(1) -> logoff
SIGINT(2) -> Ctrl+C
SIGKILL(9)-> force quit
SIGTERM(15)->quit
SIGCONT(18)->continue

kill -15 procID atau
kill -s SIGTERM procID atau
kill -SIGTERM procID atau
kill -TERM procID
sigsama semua
kill %1 (%jobid)

UNIT 4
FHS: filesystem hierarchy standard
Device file name standard:

1. SCSI/SATA :

/dev/sda (primary)

/dev/sda1 (primary partition 1)

/dev/sda2 (primary partition 2)

2. IDE/PATA(ATA) :

/dev/hda (primary)
/dev/hda1 (primary partition 1)
/dev/hda2 (primary partition 2)
tune2fs -j /dev/hda7
:add journal filesystem function on ext2, and change the filesystem to ext3

tune2fs -i
:configure the maximum time interval to check the filesystem

fsck
:fsck is used to check and optionally repair one or more Linux file systems. filesys can be a device name (e.g. /dev/hdc1, /dev/sdb2), a mount point (e.g. /, /usr, /home), or an ext2 label or UUID specifier (e.g. UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root)

df -interval
:monitor inode usage

/etc/fstab

swapon –a
:activate all swap partitions at once. The swapon utility will search through your /etc/fstab file to identify all defined swap partitions and will mount them.

swapoff –a
:deactivate all currently enabled swap partitions.

mount –t file_system_type device mount_point
mount –t ext4 /dev/sdb1 /mnt/extraspace
:create the ext4 file system on the first partition on the second hard disk in your system and now you want to mount it in a directory named /mnt/extraspace.

mount –o loop filename.iso mount_point
:mount an ISO image in the file system, allowing you to access the files within it without burning it to an optical disc

mkdir /task
df -h
mount /dev/sdb2 /task
df -h

GRUB = GRand Unified Bootloader
MBR = Master Boot Record

GRUB = GRand Unified Bootloader

MBR = Master Boot Record

Bootloader setting file:
/boot/grub/menu.lst
/boot/grub/grub.conf

Command to install grub?
grub-install /dev/hdb

Kernel parameter
/proc/cmdline

To change bootloader from sda1 to sda2:
grub edit > kernel /boot/vmlinuz-2.6.18-6.686 ro root=/dev/sda2

Runlevel
Runlevel description file : /etc/inittab
0 : shutdown
1 : single user
2 : multi user ( text login, NFS server stopped)
3 : multi user ( cui login)
5 : multi user (gui login)
6 : reboot

How to set init level to 3?
id:3:initdefault:

Command to edit runlevel?
init (eg. /sbin/init 5 #change the runlevel to 5)
telinit

How to check the current run level?
/sbin/runlevel
N 3
-> it means, the current run level is 3. And N means there were no change since the first run level setting.
5 3
-> it means, the current run level is 3. Runlevel was set early as 5.

GRUB2 vs GRUB Legacy:
1. GRUB Legacy → stage1, stage 1.5, stage 2
GRUB2 → boot.img & core.img

Shutdown option
-h : shutdown and halt
-r : shutdown and reboot
-f : shutdown and not performing the fsck when starting back the system
-F : shutodwn and perform fsck when starting back the system
-k : notify users who are currently logging in the system, but not performing the shutdown process
now : shutdown now
HH:MM set the time of shutdown
+MIN set the minute to shutdown

##Linux Installation and Package

/etc/lilo.conf
LILO = Linux Loader
After editing /etc/lilo.conf, we need to execute the below command:
/sbin/lilo
How to install lilo?
1. MBR (Master Boot Record)
2. The first sector of root partition
3. floppy disk

dpkg command setting file:
/etc/dpkg/dpkg.cfg

Install package with dpkg command:
dpkg -i ssh_1.2.3-9.deb

dpkg option cheat sheet:
http://www.cyberciti.biz/howto/question/linux/dpkg-cheat-sheet.php

reconfigure an already installed packages:
dpkg-reconfigure

apt-get
apt ( Advanced Packaging Tool)

YUM (Yellowdog Update Manager)
configuration file = /etc/yum.conf
Repository kept in /etc/yusm.repos.d

RPM

One response to this post.

  1. Info sangat menarik, sukses ya mas.. , Adrianne

    Reply

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 )

Facebook photo

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

Connecting to %s

%d bloggers like this: