Linux command for LPIC preparation

history -d 100
history -c = clears the history

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.

-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

:! 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
renice can also be done by the command top; type r; input the PID of a process; then put the nice value

=display all the background and foreground running job.
SIGHUP(1) -> logoff

SIGINT(2) -> Ctrl+C

SIGKILL(9)-> force quit


kill -15 procID atau

kill -s SIGTERM procID atau

kill -SIGTERM procID atau

kill -TERM procID

sama semua
kill %1 (%jobid)

FHS: filesystem hierarchy standard
Device file name standard:


/dev/sda (primary)

/dev/sda1 (primary partition 1)

/dev/sda2 (primary partition 2)


/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 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


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:

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

Kernel parameter

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

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?

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

How to check the current run level?
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

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

dpkg command setting file:

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

dpkg option cheat sheet:

reconfigure an already installed packages:

apt ( Advanced Packaging Tool)

One response to this post.

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


Leave a Reply

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

You are commenting using your 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

%d bloggers like this: