Essential Linux Command

Linux Command

*** ls command ***
Lists hidden files also. If a file or directory name starts with a dot, it is referred to as hidden.

Displays file types. Shows / for directories, * for executable files, @ for symbolic links and nothing for text files.

Displays long listing with file sizes in human readable format.

Displays long listing with detailed file information including file type, permissions, link count, owner, group, size, date and time of last modification, and name of the file.

Displays long listing of the specified directory, but hides its contents.

Lists contents of the specified directory and all its sub-directories (recursive listing).

Lists all files sorted by date and time with the newest file first.

Lists all files sorted by date and time with the oldest file first.

To list files in the current directory with detailed information, use one of the following:
# ll
# ls -l

*** pwd Command ***
The pwd (present working directory) command displays a user’s current location in the directory tree.

*** cd Command ***
The cd (change directory) command is used to navigate the directory tree.

To go back to the home directory, issue either of the following two commands:
$ cd
$ cd ~

To go to the root directory, use the forward slash character:
$ cd /

*** tty Command ***
This command displays the pseudo terminal where you are currently logged in:
$ tty

or you may also type this command to know who you are:
$ who am i
$ whoami

*** whoami Command ***
The whoami (who am i) command displays the username of the user that executes this command.

*** logname Command ***
The logname (login name) command shows the name of the real user that logs in initially. If that user uses the su command to switch identity, the logname command, unlike the whoami command, still shows the real username.

*** id Command ***
The id (identification) command displays a user’s UID (user identification), username, GID (group identification), group name, all secondary groups that the user is a member of, and SELinux security context:
$ id
uid=500(admin) gid=500(admin) groups=500(admin) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

*** groups Command ***
The groups command lists all groups that a user is a member of:
$ groups

*** last Command ***
The last command reports the history of successful user login attempts and system reboots by reading the /var/log/wtmp file. This file keeps a record of all login and logout activities including login time, duration a user stayed logged in, and tty where the user session took place.

To list only system reboot details:
# last reboot

There is another command that lists more detailed information on recent logins and reboots. This command is utmpdump and is executed the following way:
# utmpdump /var/log/wtmp

*** uname Command ***
The uname command produces basic information about the system. Without any options, this command displays the operating system name only. You can use the -a option to get more information.
# uname
# uname -a
Linux localhost.localdomain 2.6.32-358.el6.i686 #1 SMP Thu Feb 21 21:50:49 UTC 2013 i686 i686 i386 GNU/Linux

*** hostname Command ***
The hostname command displays the system name:
# hostname

*** date Command ***
The date command displays current system date and time.

*** hwclock Command
The hwclock command displays the date and time based on the hardware clock.

*** cal Command
The cal (calendar) command displays the calendar for the current month

*** which Command
The which command shows the absolute path of the command that will execute if run without using the absolute path
# which date

*** whereis Command
The whereis command displays the binary name and the full pathname of the command along with the location of its manual pages:
$ whereis date
date: /bin/date /usr/share/man/man1p/date.1p.gz /usr/share/man/man1/date.1.gz

*** wc Command
The wc (word count) command displays number of lines, words, and characters (or bytes) contained in a text file or input supplied.
# Option
Prints line count.

Prints word count.

Prints byte count.

Prints character count.

*** wall Command
The wall command is used to broadcast a message to all logged in users on the system.


*** USING tar ***
Command option when using tar command:
Creates a tarball.

Specifies a tarball name.

Compresses a tarball with bzip2 command.

Appends files to the end of an existing tarball. Does not append to compressed tarballs.

Lists contents of a tarball.

Appends files to the end of an existing tarball if the specified files are newer. Does not append to compressed tarballs.

Verbose mode.

Extracts from a tarball.

Compresses a tarball with gzip command.

To create a tarball called /tmp/home.tar of the /home directory:
# tar cvf /tmp/home.tar /home

To create a tarball called /tmp/files.tar containing multiple files located in the /etc directory:
# tar cvf /tmp/files.tar /etc/host.conf /etc/ntp.conf /etc/yum.conf

To append files located in the /etc/xinetd.d directory to home.tar:
# tar rvf /tmp/home.tar /etc/xinetd.d

To list the contents of home.tar:
# tar tvf /tmp/home.tar

To extract files from files.tar:
# tar xvf /tmp/files.tar

To create a tarball called /tmp/home.tar.gz of the /home directory and compress it with gzip:
# tar cvzf /tmp/home.tar.gz /home

To create a tarball called /tmp/ of the /home directory and compress it with bzip2:
# tar cvjf /tmp/ /home

*** Compression Tools ***

*** Using zip and unzip
The following example compresses three files into one called /tmp/
# zip /tmp/ /etc/host.conf /etc/ntp.conf /etc/yum.conf

To uncompress the three files, issue the unzip command:
# unzip /tmp/


# The lost+found Directory (/lost+found)
This directory holds files that become orphan after a system crash. An orphan file is a file that has lost its name.

# Creating Files Using the touch Command

#Creating Files Using the cat Command
The cat command allows you to create short text files:
$ cat > newfile

$ ll
total 12
-rw-rw-r–. 1 aghori aghori 48 Jul 28 07:21 file1
-rw-rw-r–. 1 aghori aghori 0 Jul 28 07:30 newfile
drwxrwxr-x. 3 aghori aghori 4096 Jul 28 07:28 scripts.dir1
drwxrwxr-x. 3 aghori aghori 4096 Jul 28 07:30 scripts.dir2
Column 1: The 1st character tells the type of file. The next 9 characters indicate permissions. File permissions are explained at length in Chapter 04 “File Permissions, Text Editors, Text Processors & The Shell”.

Column 2: Displays the number of links that the file or the directory has.

Column 3: Shows the owner name of the file or directory.

Column 4: Displays the group name that the owner of the file or directory belongs to.

Column 5: Shows the file size in bytes. For directories, this number reflects the number of blocks being used by the directory to hold information about its contents.

Columns 6, 7, and 8: Display the month, day of the month, and the time at which the file or directory was created or last accessed/modified.

Column 9: Shows the name of the file or directory.

*** File and Directory Control Attributes

Effect on File or Directory

a (append)

File can only be appended.


Prevents updating access time.

c (compressed)

File is automatically compressed on the disk.

d (dump)

File cannot be backed up with the dump command.

Changes on a directory are written synchronously to the disk.

e (extent format)
File uses extents for mapping the blocks on disk. Set on all files by default.

i (immutable)
File cannot be changed, renamed, or deleted.

j (journaling)
File has its data written to the journal before being written to the file itself. See Chapter 10 “File Systems & Swap” for details on journaling.

S (synchronous)
Changes in a file are written synchronously to the disk.

To list current attributes on install.log:

# lsattr install.log
————-e- install.log

# chattr +i install.log
# lsattr install.log
—-i——–e- install.log

Now, try deleting this file as root:
# rm install.log
rm: remove regular file `install.log’? y
rm: cannot remove ‘install.log’: Operation not permitted

To allow only the append operation on the file:
# chattr +a install.log
# cat /etc/fstab >> install.log

To unset both attributes:
# chattr -ia install.log

*** diff

Compare between two files or two directories

$ diff -c file1 file2
$ diff -c folder1 folder2

Copy folder to a folder
$ cp -r folder2 folder1

*** find Command
The find command recursively searches the directory tree, finds files that match the specified criteria, and optionally performs an action. This powerful tool can be customized to look for files in a number of ways. The search criteria may include searching for files by name, size, ownership, group membership, last access or modification time, permissions, file type, and inode number.

To find files in /home with ownership set to aghori and group membership set to any group but aghori:
# find /home -user aghori -not -group aghori

To find files in the /etc/rc.d directory that were modified more than 120 days ago:
# find /etc/rc.d -mtime +120

To find files in the /etc/rc.d directory that have not been accessed in the last 90 days:
# find /etc/rc.d -atime -90

To find files in the /etc/rc.d directory that were modified exactly 10 days ago:
# find /etc/rc.d -mtime 10

To search for core files in the entire directory tree and delete them as found without prompting for confirmation:
# find / -name core -exec rm {} \;

*** Soft Link
A soft link (a.k.a. a symbolic link or a symlink) makes it possible to associate one file with another. It is similar to a shortcut in MS Windows where the actual file is resident somewhere in the directory structure but you may have multiple shortcuts or pointers with different names pointing to it.
$ ln -s file1 newfile_softlink
$ ll -i
36 -rw-rw-r–. 1 aghori aghori 0 Jul 28 07:30 file1
32 lrwxrwxrwx. 1 aghori aghori 7 Jul 28 14:23 newfile_softlink -> file1

If you remove the original file (file1 in this example), the link newfile_softlink will stay but points to something that does not exist.

*** Hard Link
A hard link associates two or more files with a single inode number. This allows the files to have identical permissions, ownership, time stamp, and file contents. Changes made to any of the files are reflected on the other linked files. All files actually contain identical data.
$ln newfile2 newfile20

After creating the link, run ll with the -i option:

$ ll -i
32 -rw-rw-r–. 2 aghori aghori 0 Jul 28 14:29 newfile2
32 -rw-rw-r–. 2 aghori aghori 0 Jul 28 14:29 newfile20

*** Changing Access Permissions
Add the execute permission for the owner and run the ll command to verify:
$ chmod u+x file1

Add the write permission for group members and public and run the ll command to verify:
$ chmod go+w file1

Add the execute permission for the file owner and run the ll command to verify:
$ chmod 544 file2

Add the write permission for the owner and run the ll command to verify:
$ chmod 744 file2

*** File Ownership and Group Membership
To change ownership from user1 to user2:
# chown user2 file10
# ll file10
-rw-r—–. 1 user2 user1 0 Jul 29 07:00 file10

To change group membership from user1 to user2:
# chgrp user2 file10
# ll file10
-rw-r—–. 1 501 user2 0 Jul 29 07:00 file10

To modify both ownership and group membership in one go:
# chown user1:user1 file10
# ll file10
-rw-r—–. 1 user1 user1 0 Jul 29 07:00 file10

To modify recursively (-R option) all files and sub-directories under dir1 to be owned by user2 and group user2:
# chown -R user2:user2 dir1

*** Executing a Command Immune to Hangup Signals
For example, to copy /sdata1 directory recursively containing 20GB of data to /sdata2, issue the cp command as follows:
# nohup cp -av /sdata1 /sdata2 &

Files to copy when migrating your Lotus Notes installation to a new computer (Windows Mac)



You have a new workstation to which you need to transfer your Lotus Notes configurations and data. What are the default files a user needs to copy over from the old workstation to the new workstation?

Resolving The Problem

The necessary system files are as follows:
1. Personal Address Book (typically Names.nsf; check the NAMES entry in the Notes.ini to confirm).
2. Bookmark.nsf
3. Desktop.ndk
4. Notes.ini
5. The user’s .ID file.


Folder location

The user’s.nsf
The user’s.ID

Folder location
/Users/{YourUserName}/Library/Application Support/IBM Notes Data

You may use the below code to change directory to the above folder
cd ‘/Users/{YourUserName}/Library/Application Support/IBM Notes Data’

Berbagi cerita tentang Furusato Nouzei ふるさと納税 (pajak kampung halaman) di Jepang

Beberapa pekan lalu ikut kajian tentang berbagi pengalaman terkait Pajak di Jepang dan berbagai bentuk kemudahan dan variasi penyalurannya. Salah satu yang cukup menarik perhatian saya adalah tentang Furusato Nouzei (ふるさと納税) atau pembayaran pajak ke Kampung Halaman.

Furusato nozei adalah pengalihan sebagain pembayaran pajak oleh orang-orang yang tinggal di perkotaan ke daerah-daerah dengan maksud untuk menggerakkan ekonomi di daerah yang memiliki hak otonomi di Jepang. Hal ini dikarenakan di daerah-daerah saat ini populasi orang tua-tua meningkat (bukan usia produktif pajak) sehingga pendapatan pajaknya menurun sedangkan di kota pendapatan pajaknya naik sehingga perlu diratakan dengan furusato nozei.

Kabarnya, Furusato nozei sudah berlaku cukup lama di Jepang, hanya saja mulai tahun 2016 ketika ada perubahan atauran dan administrasi, proses pengajuannya menjadi jauh lebih mudah. Banyak orang yang menggunakan furusato nozei. Salah satu yang menarik sehingga furusato nozei banyak diminati adalah adanya tanda terima kasih dari kota yang menerima pajak kita berupa barang-barang yang nilai pasarnya bisa cukup tinggi mencapai sekitar 30-40 persen bahkan ada yang sampai 50 persen dari donasi yang kita berikan.

Kemudahan aplikasi Furusato Nouzei semakin terbantu dengan fasilitas belanja online dari Rakuten.
Salah satunya bisa merujuk pada link berikut:

Ada banyak pilihan yang bisa disesuaikan dengan minat dan kebutuhan kita. Nah, karena saya sangat suka mengkonsumsi buah Nashi (pear Jepang), pilihan saya jatuh pada salah satu kota yang menyediakan paket Furusato Nouzei seharga 10,000 Yen dengan hadiah berupa buah pear sekitar 5-6kg (kurang lebih 9 butir buah pear Jepang ukuran besar). Saya pun memberanikan diri untuk membeli paket tersebut secara online.

Sekitar 1 bulan kemudian, paket buah pear Jepang yang saya beli dari Rakuten Furusato Nouzei pun tiba di rumah. Ternyata di luar perkiraan, buah pear Jepang yang dikirimkan ukurannya besar-besar dan ranum. Terima kasih Furusato Nouzei!

Untuk referensi, silakan menyimak materi detail seputar Furusato Nouzei:

Slide Materi


Catatan perjalanan Haji dari Jepang (Bagian 2)


Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang.

Assalamualaikum warrahmatullah akhifillah dan ukhtifillah yang diberkahi Allah, aamiin..

Berangkat Haji maupun Umrah dari Jepang merupakan rezeki yang dobel dobel menurut saya, alhamdulillah..


Diberikan kemudahan untuk tidak mengalami ujian “waiting list” ketika berangkat haji, karena Jepang jumlah penduduk Muslimnya sangat sedikit, jadi tidak harus menunggu lama untuk berangkat haji maupun umrah ( yang waiting list uang dan kondisi ya?) hehe
Menambah Saudara Islam, jamaah dari beraneka macam rupa, dari bahasa, negara,(Indonesia, Malaysia, India, Pakistan, Bangladesh, Persia, Jepang asli ^^, dan Cina Muslim) otomatis jadi harus bisa bahasa jepang dan inggris, walaupun jamaah Indonesia juga banyak , tapi klo cuma ngobrol sesama Indoneia-ers gak gaul kita hehe..
Biaya yang dimudahkan, insya Allah, Allah pasti memberikan kemudahanNya bagi hambaNya yang berniat dan ikhtiar haji. Biaya haji dari Jepang kurang lebih sama dengan biaya ONH plus Indonesia, dengan kemudahan kemudahan yang didapat berupa pendapatan yang bisa ditabung lebih cepat dari hasil baito atau arubaito (tentunya hal ini relatif ya.. )
Suhu dan keadaan yang sudah terkondisikan, bagi yang sudah terbiasa tinggal di jepang pasti sudah gak kaget dengan jalan kaki jauh dan naik tangga ^0^ Ketika menjalankan ibadah haji, satu hari nya mungkin kita bisa berjalan kaki sejauh 10 km.. ^0^// Suhu ketika musim panas di Jepang bisa mencapai 38-40 C bisa dijadikan pelajaran berharga untuk belajar sabar ketika kita berada di tanah suci (ketika kami berhaji, suhu paling tinggi sekitar 42 C)

Catatan perjalanan Haji dari Jepang (PENDAHULUAN)


Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang.

Assalamualaikum warrahmatullah akhifillah dan ukhtifillah yang diberkahi Allah, aamiin..

Alhamdulillah, segala puji serta syukur selalu kita panjatkan selalu kepada Allah, Tuhan semesta alam yang memberikan kita banyak kenikmatan, dan salam shalawat kepada imam kita Rasulullah sallallahu alaihi wasallam beserta keluarga san sahabat Beliau.

Sungguh tak bisa dilupakan ketika kami diberikan kesempatan Allah untuk datang ke rumahNya pada hari itu. Bangunan berbentuk persegi, diselubungi kain hitam bertuliskan lafadz Syahadat, di salah satu sudutnya terdapat Hajar Aswad, dan pintunya bernama Mulatazam, bangunan itu tiada lain adalah Ka`bah . Bangunan yang selama ini kita sholat menghadapnya.

Hampir setahun yang lalu kami melakukan Thawaf mengelilingi Ka`bah tapi rasanya masih kemarin kami melakukannya, dan rasanya ingin sekali kami kembali lagi ke sana ( ngarep rezeki Allah ^O^)

Insya Allah akhifillah dan ukhtifillah diberikan kesempatan serupa untuk bisa pergi ke Tanah suci secepatnya ^o^// dan bagi yang sudah pergi semoga bisa ke sana lagi dalam ibadah umrah ( jangan lupa ajak ajak ^0^ )

Cuap cuap pendahuluan sampai sini aja deh hehehe,,

Sampai bertemu di postingan selanjutnya ^^

Afwan lahir batin, jazakillah khoiran katsiran

Wassalamualaikum Warrahmatullah













Linux command for LPIC preparation

LPIC 1 Objectives

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

Continue reading

How to find a word (or string) inside a folder?

grep -nr yourString /directory

./fileA:10:. yourString
./fileB:11:. yourString
./fileC:13:. yourString

%d bloggers like this: