Linux - Basic Command                                 Home : www.sharetechnote.com

 

 

 

This page will list the most basic Linux commands that you would use most commonly and the list will get longer as times goes. There are a group of commands that are pretty often used but not in this page, e.g, Network/IP related command or System Management commands. These commands are not listed here because they will be posted as a separate page.

 

 

List of the command in the order of usage

 

Followings are the list of Linux commands with respect to how often it is used. This is based on my own usage, you would have different order depending on your usage. (You can get the list in Alphabetical Order in following section)

 

Linux Command

DOS Command

Description

ls

dir

List the files in a directory

Usage : 'ls' or 'ls directoryname'

cd

cd

Change directory

sudo

 

provide the super user previlege

mount

 

map an hardware to a specific directory

cat

type

Display a contents of a file

grep find find a specified string from a file or the output of other command
find   find files

pwd

 

Display the current path (location of current directory)

cp

copy

Copy a file

rm

del

Delete a file

mkdir

mkdir

Make a directory

whoami

 

Display the current user

ps  

Display the list of processes currently running on a machine

(options : -al, -Al, -aux)

kill   kill a specific process
chmod   change access property (read, write, executable) for a file or a directory
echo $PATH   shows the PATH that has been specified in the system
reset   clear screen (similar to 'cls' in DOS command)
./ (dot slash)   This is not a command.. it indicates 'current directory'
fdisk -l   list the information of all the disk information that are connected
lsmod   list the status of all the modules (device drivers) in the Linux Kernel
apt-get  

a command-line tool for working with APT(Advanced Packaging Tool) software packages.

apt-file   search a package name that contains a specified file
yum  

YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems

dd diskdump dump a specified area of a disk into a file (binary file) or consol
xxd   view (print out) the contents of a binary file
lscpu   show (list) the information about the CPU

lsblk

 

prints all block devices (except RAM disks)

lsusb   list up all the usb

objdump

  convert an executable binary file to assembly code
uname -a   show the linux kernel information
lsb_release -a  

show the linux distribution information, print out information on operating system

dmesg   shows the boot sequenec log
which   find the path of a specified file/link (mostly executable files)
shutdown   shutdown or reboot
env   print all the environment variables
printenv   print all the environment variables
df  

print disk usages of file system

du   print disk usage
passwd   changing the password
cmp  

compare two files of any type and writes the results to the standard output

ifconfig   List or configure Network Interface and. Refer to Network page for the details
touch   Create empty file (files)
top  

monitor processes and system resource usage (This is similar to the TaskManager in Windows)  

     

 

 

 

List of the command in Alphabetical Order

 

 

Linux Command

DOS Command

Description

./ (dot slash)   This is not a command.. it indicates 'current directory'
apt-file   search a package name that contains a specified file
apt-get   a command-line tool for working with APT(Advanced Packaging Tool) software packages.
cat type Display a contents of a file
cd cd Change directory
chmod   change access property (read, write, executable) for a file or a directory
cmp   compare two files of any type and writes the results to the standard output
cp copy Copy a file
dd diskdump dump a specified area of a disk into a file (binary file) or consol
df   print disk usages of file system
dmesg   shows the boot sequenec log
du   print disk usage
echo $PATH   shows the PATH that has been specified in the system
env   print all the environment variables
fdisk -l   list the information of all the disk information that are connected
find   find files
grep find find a specified string from a file or the output of other command
ifconfig   List or configure Network Interface and. Refer to Network page for the details
kill   kill a specific process
ls dir List the files in a directory
Usage : 'ls' or 'ls directoryname'
lsb_release -a  

show the linux distribution information, print out information on operating system

lsblk   prints all block devices (except RAM disks)
lsusb   list up all the usb
lscpu   show (list) the information about the CPU
lsmod   list the status of all the modules (device drivers) in the Linux Kernel
mkdir mkdir Make a directory
mount   map an hardware to a specific directory
objdump   convert an executable binary file to assembly code
passwd   changing the password
printenv   print all the environment variables
ps  

Display the list of processes currently running on a machine

(options : -al, -Al, -aux)

pwd   Display the current path (location of current directory)
reset   clear screen (similar to 'cls' in DOS command)
rm del Delete a file
shutdown   shutdown or reboot 
sudo   provide the super user previlege
top  

monitor processes and system resource usage (This is similar to the TaskManager in Windows)  

touch   Create empty file (files)
uname -a   show the linux kernel information
which   find the path of a specified file/link (mostly executable files)
whoami   Display the current user
xxd   view (print out) the contents of a binary file
yum   YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems

 

 

 

ls

 

: List the files in a directory

 

 

Example : print out the files and directories within the current working directory

 

$ ls

 

bin    dev   initrd.img      lib64       mnt   root  selinux  tmp  vmlinuz

boot   etc   initrd.img.old  lost+found  opt   run   srv      usr  vmlinuz.old

cdrom  home  lib             media       proc  sbin  sys      var

 

 

Example : print out all the files and directory within the current working directory with property informal

 

$ ls -al

 

drwxr-xr-x  24 root root  4096 May 30 02:48 .

drwxr-xr-x  24 root root  4096 May 30 02:48 ..

drwxr-xr-x   2 root root  4096 May 30 23:45 bin

 

''''''

drwxr-xr-x  10 root root  4096 Feb 13 17:07 usr

drwxr-xr-x  13 root root  4096 May 30 09:18 var

lrwxrwxrwx   1 root root    29 May 30 02:48 vmlinuz -> boot/vmlinuz-3.5.0-31-generic

lrwxrwxrwx   1 root root    29 May 30 09:57 vmlinuz.old -> boot/vmlinuz-3.5.0-23-generic

 

 

Example : print out the list in all the sub directories ('R' stands for Recursive)

 

$ ls -R

 

 

Example : print out all the list in page by page. When it goes over a page, the list stops at the end of a page with '-- More --'. It shows you one more line as you press Enter key.   

 

$ ls -al | more

 

drwxr-xr-x  24 root root  4096 May 30 02:48 .

drwxr-xr-x  24 root root  4096 May 30 02:48 ..

drwxr-xr-x   2 root root  4096 May 30 23:45 bin

 

''''''

drwxr-xr-x  10 root root  4096 Feb 13 17:07 usr

drwxr-xr-x  13 root root  4096 May 30 09:18 var

lrwxrwxrwx   1 root root    29 May 30 02:48 vmlinuz -> boot/vmlinuz-3.5.0-31-generic

lrwxrwxrwx   1 root root    29 May 30 09:57 vmlinuz.old -> boot/vmlinuz-3.5.0-23-generic

-- More -- <-- It shows next line as you press [Enter]. Press 'Q' to quit

 

 

Example : List the files and directories in a specified folder

 

$ ls /var

 

backups  cache  crash  games  lib  local  lock  log  mail  opt  run  spool  tmp

 

 

Example : print out all the list which contains the specified string. Following example lists all the file name and directory names which contains the string 'edit' in it.

 

$ ls -al usr/bin | grep 'edit'

 

lrwxrwxrwx  1 root root          20 Jan 19 15:43 desktop-file-edit -> desktop-file-install

lrwxrwxrwx  1 root root          11 Jan 19 15:43 edit -> run-mailcap

-rwxr-xr-x  1 root root        2060 May  6  2015 editdiff

...

-rwxr-xr-x  1 root root      645880 Feb 10  2016 xedit

 

 

 

find

 

: find files

 

Example : list all the files in current directory and sub directories

 

$ find

 

 

Example : list all the files in current directory and sub directories

 

$ find .

 

 

Example : list all the files with a specified pattern within the current directory and sub directories. This example list all the filenames starting with 'Hello'.

 

$ find . -name 'Hello*'

          or

$ find  -name 'Hello*'

 

 

Example : list all the files with a specified pattern in the whole PC. This example list all the filenames starting with 'Hello'.

 

$ sudo find / -name 'Hello*'

          or

$ sudo find / | grep 'Hello'

 

NOTE : I put 'sudo' here because there can be many folders which has a limitted permission. If you don't put sudo, this would not search the folder with limited permission.

 

 

 

pwd

 

: Shows the path for the current directory

 

Example

 

#pwd

 

/home/sharetechnote

 

 

 

sudo

 

: Provide the super user previlege

 

Example :

 

$ ifconfig eth0 192.168.1.2 up

 

SIOCSIFADDR: Permission denied  <-- this Linux does not allow to change ifconfig
SIOCSIFFLAGS: Permission denied

SIOCSIFFLAGS: Permission denied

 

$ sudo ifconfig eth0 192.168.1.2 up <-- try the same command with super user previlege

 

[sudo] password for sharetechnote: <-- type in the password and then it will allow the command to be executed

 

 

 

rm

 

: delete a file or directory

 

Example :

 

# rm usbstick

 

Example : you may get an error message when you remove a directory with rm as shown below. In that case, you may use '-r' or '-rf' option to remove the whole directory.

 

# rm usbstick

 

rm: cannot remove `usbstick': Is a directory <-- rm failed to remove usbstick

 

# rm -r usbstick <-- try with '-r' option

 

# rm -rf usbstick <-- try with '-rf' option

 

 

 

cat

 

: View the contents of a file

 

Example :

 

$ cat temp.txt

 

Contents of 'temp.txt' will show up here

....

 

 

Example :

 

$ cat file1 file2

 

Contents of file1 and file2 will show up in sequence

....

 

 

Example :

 

$ cat file1 file2 > file3

 

Contents of file1 and file2 will be out to file3. In other words, file1 and file2 concatenated and create file3.

....

 

 

 

mount

 

: map an hardware to a specific directory.

 

Example 1 : map a usb stick to a directory (This is done on Ubuntu)

 

Step 1: Create a directory to be mapped to a IO device (you can use an existing directory as well)

 

# mkdir /mnt/usbstick

 

Step 2: Make it sure that the directory is created properly.

 

# ls /mnt

 

usbstick

 

Step 3: Make it sure that the directory is created properly.

 

# mount -t vfat -o rw,users /dev/sda2 /mnt/usbstick

<-- with vfat, you can mount usbstick which is formated on Windows

<-- /dev/sda2 is the usb port that my usb stick is plugged in. you have to make it sure that you have specified the right port number. you may try 'fdisk -l' command to figure out which device you have to use for this mount

 

Step 4: check if it is properly mounted. The simplest way would be to use 'ls' and see if it shows the contents that is stored in the stick.

 

# ls /mnt/usbstick

 

temp.txt

 

 

 

ps

 

: Display the list of processes currently running on a machine. It is same as "Processe" tab on Task Manager in Windows.

 

Example :

 

# ps

 

PID     TTY       TIME   CMD

2079   pts/1    00:00:00 su

2087   pts/1    00:00:00 bash

16819  pts/1    00:00:00 ps

 

 

Example :

 

# ps -al  <-- Note 'a' is in lower case

 

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

4 S     0  2079  2021  0  80   0 - 15478 wait   pts/1    00:00:00 su

0 S     0  2087  2079  0  80   0 -  6810 wait   pts/1    00:00:00 bash

0 R     0 16822  2087  0  80   0 -  3482 -      pts/1    00:00:00 ps

 

 

Example :

 

# ps -Al  <-- Note 'a' is in upper case

 

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD

4 S     0     1     0  0  80   0 -  6117 poll_s ?        00:00:01 init

1 S     0     2     0  0  80   0 -     0 kthrea ?        00:00:00 kthreadd

1 S     0     3     2  0  80   0 -     0 run_ks ?        00:00:07 ksoftirqd/0

1 S     0     6     2  0 -40   - -     0 cpu_st ?        00:00:01 migration/0

1 S     0     7     2  0 -40   - -     0 watchd ?        00:00:00 watchdog/0

1 S     0    20     2  0  60 -20 -     0 rescue ?        00:00:00 cpuset

1 S     0    21     2  0  60 -20 -     0 rescue ?        00:00:00 khelper

5 S     0    22     2  0  80   0 -     0 devtmp ?        00:00:00 kdevtmpfs

...

4 S     0   837     1  0  80   0 - 19760 poll_s ?        00:00:00 modem-manager

5 S     0   838     1  0  80   0 -  5297 poll_s ?        00:00:00 bluetoothd

5 S     0   849     2  0  70 -10 -     0 rfcomm ?        00:00:00 krfcommd

5 S     0   851     1  0  80   0 - 61343 poll_s ?        00:00:24 NetworkManager

.....

0 S  1000  1729  1721  0  80   0 -  2845 unix_s ?        00:00:00 cat

....

0 S  1000  2021  2009  0  80   0 -  6799 wait   pts/1    00:00:00 bash

4 S     0  2079  2021  0  80   0 - 15478 wait   pts/1    00:00:00 su

0 S     0  2087  2079  0  80   0 -  6810 wait   pts/1    00:00:00 bash

....

0 S  1000 14645     1  3  80   0 - 264797 poll_s ?       00:22:43 firefox

 

 

Example :

 

# ps -aux

 

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root         1  0.3  0.2 119696  5756 ?        Ss   17:12   0:01 /sbin/init spla

root         2  0.0  0.0      0     0 ?        S    17:12   0:00 [kthreadd]

root         3  0.0  0.0      0     0 ?        S    17:12   0:00 [kworker/0:0]

root         4  0.0  0.0      0     0 ?        S<   17:12   0:00 [kworker/0:0H]

root         6  0.0  0.0      0     0 ?        S<   17:12   0:00 [mm_percpu_wq]

root         7  0.0  0.0      0     0 ?        S    17:12   0:00 [ksoftirqd/0]

root         8  0.0  0.0      0     0 ?        S    17:12   0:00 [rcu_sched]

root         9  0.0  0.0      0     0 ?        S    17:12   0:00 [rcu_bh]

...

root        80  0.0  0.0      0     0 ?        S    17:12   0:00 [scsi_eh_1]

root        81  0.0  0.0      0     0 ?        S<   17:12   0:00 [scsi_tmf_1]

root        82  0.0  0.0      0     0 ?        S    17:12   0:00 [kworker/u2:2]

root        87  0.0  0.0      0     0 ?        S<   17:12   0:00 [ipv6_addrconf]

root       112  0.0  0.0      0     0 ?        S<   17:12   0:00 [charger_manage

root       113  0.0  0.0      0     0 ?        S    17:12   0:00 [kworker/u2:4]

root       155  0.0  0.0      0     0 ?        S<   17:12   0:00 [kworker/0:1H]

..

root       704  0.0  0.1  29008  3008 ?        Ss   17:12   0:00 /usr/sbin/cron

root       710  0.0  0.4 291404  8184 ?        Ssl  17:12   0:00 /usr/lib/accoun

root       735  0.0  1.0 136076 20488 ?        Ssl  17:12   0:00 /usr/lib/snapd/

syslog     744  0.0  0.1 256396  3368 ?        Ssl  17:12   0:00 /usr/sbin/rsysl

avahi      749  0.0  0.1  44908  3504 ?        Ss   17:12   0:00 avahi-daemon: r

root       750  0.0  0.8 455848 17076 ?        Ssl  17:12   0:00 /usr/sbin/Netwo

avahi      758  0.0  0.0  44784   336 ?        S    17:12   0:00 avahi-daemon: c

root       763  0.0  0.0   4396  1316 ?        Ss   17:12   0:00 /usr/sbin/acpid

root       812  0.0  0.2  65508  5640 ?        Ss   17:12   0:00 /usr/sbin/sshd

...

root       865  0.0  0.1  16128  3728 ?        S    17:12   0:00 /sbin/dhclient

root       866  0.0  0.1  16128  3724 ?        S    17:12   0:00 /sbin/dhclient

nobody     888  0.0  0.1  52864  3960 ?        S    17:12   0:00 /usr/sbin/dnsma

root       953  0.0  0.3 228240  6364 ?        Sl   17:12   0:00 lightdm --sessi

jaekuryu   976  0.0  0.2  45248  4652 ?        Ss   17:12   0:00 /lib/systemd/sy

jaekuryu   978  0.0  0.0  63312  1936 ?        S    17:12   0:00 (sd-pam)

...

jaekuryu  1486  0.0  0.1  42896  3928 ?        S    17:12   0:00 /usr/bin/dbus-d

...

root      2562  0.0  0.0      0     0 ?        S    17:18   0:00 [kworker/u2:0]

jaekuryu  2564  0.0  0.1  37364  3312 pts/17   R+   17:18   0:00 ps -aux

 

 

 

kill

 

: kill a specific process

 

Example :

 

#kill 14645  

<-- 14645 in this example is the PID for the process you want to kill. You have to figure out the PID using ps command

 

 

 

chmod

 

: change access property of a file or directory

 

Example :

 

#chmod 777 myfile

<-- set the access property of the file named 'myfile' to be 'readable, writeable, executable' to all users, all groups.

 

 

Example :

 

#chmod 666 myfile

<-- set the access property of the file named 'myfile' to be 'readable, writeable, Not executable' to all users, all groups.

 

 

Example :

 

#chmod 555 myfile

<-- set the access property of the file named 'myfile' to be 'readable, Not writeable, executable' to all users, all groups.

 

 

 

grep

 

: find a specified string from a file or the output of other command

 

Example :

 

#grep hello mytext

<-- search the string 'hello' from the file named 'mytext' and displays the lines containing the string 'hello'.

 

 

Example :

 

#ls -Al | grep hello

<-- execute 'ls -Al' and find the string 'hello' from the output of 'ls -Al' and displays the line containing th string 'hello'.

This may be the most common example of 'grep' command.

 

 

 

./ (dot slash)

 

: Indicate 'current directory'. When we execute a specific program, we normally type in the 'filename' and press enter. If the executable file is located in a directory specified '$PATH', it executes.. but if it is not in one of these PATH, the system would shows error saying 'No command 'xxxxx' found'. In this case, you have to specify the explicit path(location) of the executable before the filename to run it.

If you are currently at the directory where the executable, you can just put "./" before the filename.

 

Example :

 

#./myprogram

<-- run the executable named 'myprogram' located in 'current directory'. If 'myprogram' is not in the current directory, the system would show 'No command 'xxxxx' found'.

 

 

 

fdisk -l

 

 

This command lists information on all the storage device that are currently connected to the PC. it will be helpful to figure out device name to mount for external storage device (e.g, usb memory stick etc)

 

Example 1 >

 

# fdisk -l

<-- this would run when you logged in as root, but it may not work if you are not in root account

 

Example 2 >

 

# sudo fdisk -l

<-- you may try this if you are not logged in as root

 

 

 

lsmod

 

 

This command list the status of all the modules (device drivers) in the Linux Kernel

 

Example 1 >

 

# lsmod

 

Module                  Size  Used by

tcp_lp                 12663  0

ip6table_filter        12815  0

ip6_tables             26808  1 ip6table_filter

ebtable_nat            12807  0

ebtables               30758  1 ebtable_nat

sctp                  317063  18

libcrc32c              12603  1 sctp

tun                    27153  2

ipt_MASQUERADE         12880  4

iptable_nat            13011  1

nf_conntrack_ipv4      14656  1

nf_defrag_ipv4         12702  1 nf_conntrack_ipv4

nf_nat_ipv4            13199  1 iptable_nat

nf_nat                 25112  3 ipt_MASQUERADE,nf_nat_ipv4,iptable_nat

nf_conntrack           95080  5 ipt_MASQUERADE,nf_nat,nf_nat_ipv4,iptable_nat,nf_conntrack_ipv4

joydev                 17332  0

btusb                  28290  0

bluetooth             408436  2 btusb

hid_logitech_dj        18581  0

6lowpan_iphc           18591  1 bluetooth

mxm_wmi                12865  0

coretemp               13475  0

kvm_intel             143109  0

kvm                   460312  1 kvm_intel

....

 

 

 

apt-get

 

 

This is a command-line tool for working with APT(Advanced Packaging Tool) software packages. I think this is one of the most covinient command to install a new software on various linux family (e.g, Ubuntu). Basic syntax is as shown below. Refer to Linux and Unix apt-get command for the detailed tutorial.

 

apt-get [-asqdyfmubV] [-o=config_string] [-c=config_file] [-t=target_release]

        [-a=architecture] {update | upgrade | dselect-upgrade | dist-upgrade |

        install pkg [{=pkg_version_number | /target_release}]... |

        remove pkg... | purge pkg... |

        source pkg [{=pkg_version_number | /target_release}]... |

        build-dep pkg [{=pkg_version_number | /target_release}]... |

        download pkg [{=pkg_version_number | /target_release}]... |

        check | clean | autoclean | autoremove | {-v | --version} |

        {-h | --help}}

 

Since most of programming installation requires super user authority, so in most case you would use like 'sudo apt-get xxxxxx'.

 

Example >

 

I don't put any specific example here. The best way to use the command is to try Google 'How to install xxxx program (e.g, Chrome) in linux (e.g, Ubuntu) ?' and copy the whole command from the searched page and run it in your linux.

 

 

 

apt-file

 

 

: When you are running a certain program, there are cases where you get errors saying 'a xxxx file is missing'. In this case, you need to install a package that containing the missing file. Now the question is 'how can I figure out the package name that contains the missing file ?'. apt-file is the tool you need to use to find the info.

 

Note : the tool apt-file might have not been installed on your PC by defailt. In that case, you need to install the tool first by following command.

 

# sudo apt install apt-file

 

If you just installed the apt-file, you need to do following to download all the package info into your PC. Otherwise, apt-file would not be able to search the information that you need.

 

# apt-file update

 

Example >

: I will show you a sample case in which how and when you need to use this command

 

# ./qt-linux-opensource-5.0.2-x86-offline.run

// I executed a program as shown here (you would run some other program as you need. this is just my example)

// and I got following error

 

./qt-linux-opensource-5.0.2-x86-offline.run: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

// it says libXrender.so.1 is missing. So I want to find out which package has this file using following command

 

# apt-file search libXrender.so.1

// I got following result

 

libxrender1: /usr/lib/x86_64-linux-gnu/libXrender.so.1

libxrender1: /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0

libxrender1-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0

 

Then I install the package as follows

 

# sudo apt-get install libxrender1:i386

 

 

 

yum

 

 

YUM (Yellowdog Updater Modified) is an open source command-line as well as graphical based package management tool for RPM (RedHat Package Manager) based Linux systems.

 

Basic syntax of yum command is as follows. (put yum in the place of *). Refer to yum-LinuxCommand.org for detailed usage.

    * install package1 [package2] [...]

    * update [package1] [package2] [...]

    * check-update

    * upgrade [package1] [package2] [...]

    * remove | erase package1 [package2] [...]

    * list [...]

    * info [...]

    * provides | whatprovides feature1 [feature2] [...]

    * clean [ packages | headers | metadata | cache | dbcache | all ]

    * makecache

    * groupinstall group1 [group2] [...]

    * groupupdate group1 [group2] [...]

    * grouplist [hidden]

    * groupremove group1 [group2] [...]

    * groupinfo group1 [...]

    * search string1 [string2] [...]

    * shell [filename]

    * resolvedep dep1 [dep2] [...]

    * localinstall rpmfile1 [rpmfile2] [...]

    * localupdate rpmfile1 [rpmfile2] [...]

    * deplist package1 [package2] [...]

 

Example >

 

I don't put any specific example here. The best way to use the command is to try Google 'How to install xxxx program (e.g, Chrome) in linux (e.g, Fedora) ?' and copy the whole command from the searched page and run it in your linux.

 

 

 

lscpu

 

 

This command list (shows) the CPU information of the PC on which you are running the Linux.

 

Example :

 

# lscpu

 

Architecture:          x86_64

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                4

On-line CPU(s) list:   0-3

Thread(s) per core:    2

Core(s) per socket:    2

Socket(s):             1

NUMA node(s):          1

Vendor ID:             GenuineIntel

CPU family:            6

Model:                 42

Stepping:              7

CPU MHz:               800.000

BogoMIPS:              2993.22

Virtualization:        VT-x

L1d cache:             32K

L1i cache:             32K

L2 cache:              256K

L3 cache:              3072K

NUMA node0 CPU(s):     0-3

 

 

 

lsblk

 

 

This command prints all block devices (except RAM disks) in a tree format (by default)

 

Example :

 

#lsblk

 

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

sda      8:0    0 465.8G  0 disk

+-sda1   8:1    0   149G  0 part

+-sda2   8:2    0   161G  0 part

+-sda3   8:3    0     1K  0 part

+-sda5   8:5    0 151.8G  0 part /

+-sda6   8:6    0   3.9G  0 part [SWAP]

sr0     11:0    1   3.5G  0 rom  /media/ResourceCD

 

 

 

objdump

 

 

This command convert an executable binary file to assembly code. The format of the command is as follows :

    objdump <options> <file>

 

Example :

 

# objdump -D -Mintel,x86-64 -b binary -m i386 -Maddr32,data32 sda-mbr.bin

<-- convert sda-mbr.bin file into assembly code (display sda-mbr.bin in assembly code format) with using the options : -D -Mintel,x86-64 -b binary -m i386 -Maddr32,data32

 

sda-mbr.bin:     file format binary

 

Disassembly of section .data:

 

00000000 <.data>:

   0:   eb 63                   jmp    0x65

   2:   90                      nop

        ...

  3b:   00 00                   add    BYTE PTR [eax],al

  3d:   00 03                   add    BYTE PTR [ebx],al

  3f:   02 ff                   add    bh,bh

  41:   00 00                   add    BYTE PTR [eax],al

  43:   20 01                   and    BYTE PTR [ecx],al

  45:   00 00                   add    BYTE PTR [eax],al

....

 

 

 

which

 

 

This command finds path+filename of a specified file (mostly an executable program). This command searches the files through the locations specifed in PATH parameter of the operating system

 

Example :

 

# which gcc

<-- find the path where gcc is located

 

/usr/bin/gcc

 

 

 

shutdown

 

You can shutdown or reboot the linux using various options of this command. Try "shutdown --help" to find the details.

 

Example :

 

#sudo shutdown -h now

<-- shutdown (power off) the PC

 

 

Example :

 

#sudo shutdown -r now

<-- reboot the PC

 

 

 

env

 

: print out the enviroment variables

 

Example :

 

#env

 

XDG_VTNR=7

XDG_SESSION_ID=c1

CLUTTER_IM_MODULE=xim

XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/sharetechnote

SESSION=ubuntu

GPG_AGENT_INFO=/home/jaekuryu/.gnupg/S.gpg-agent:0:1

SHELL=/bin/bash

TERM=xterm-256color

VTE_VERSION=4205

QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1

WINDOWID=56623114

UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1030

GNOME_KEYRING_CONTROL=

GTK_MODULES=gail:atk-bridge:unity-gtk-module

USER=sharetechnote

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:...;36:

QT_ACCESSIBILITY=1

XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0

XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0

SSH_AUTH_SOCK=/run/user/1000/keyring/ssh

DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path

XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg

PATH=/home/sharetechnoe/bin:...:/usr/local/games:/snap/bin

DESKTOP_SESSION=ubuntu

QT_IM_MODULE=ibus

QT_QPA_PLATFORMTHEME=appmenu-qt5

XDG_SESSION_TYPE=x11

PWD=/home/sharetechnote

JOB=unity-settings-daemon

XMODIFIERS=@im=ibus

GNOME_KEYRING_PID=

LANG=en_CA.UTF-8

GDM_LANG=en_CA

MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path

IM_CONFIG_PHASE=1

COMPIZ_CONFIG_PROFILE=ubuntu-lowgfx

GDMSESSION=ubuntu

SESSIONTYPE=gnome-session

GTK2_MODULES=overlay-scrollbar

HOME=/home/sharetechnote

XDG_SEAT=seat0

SHLVL=1

LANGUAGE=en_CA:en

LIBGL_ALWAYS_SOFTWARE=1

GNOME_DESKTOP_SESSION_ID=this-is-deprecated

UPSTART_INSTANCE=

UPSTART_EVENTS=xsession started

XDG_SESSION_DESKTOP=ubuntu

LOGNAME=jaekuryu

COMPIZ_BIN_PATH=/usr/bin/

QT4_IM_MODULE=xim

XDG_DATA_DIRS=/usr/share/ubuntu:...:/var/lib/snapd/desktop

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-e6LwXeFYYa

LESSOPEN=| /usr/bin/lesspipe %s

INSTANCE=

UPSTART_JOB=unity7

XDG_RUNTIME_DIR=/run/user/1000

DISPLAY=:0

XDG_CURRENT_DESKTOP=Unity

GTK_IM_MODULE=ibus

LESSCLOSE=/usr/bin/lesspipe %s %s

XAUTHORITY=/home/sharetechnote/.Xauthority

OLDPWD=/home

_=/usr/bin/env

 

 

 

printenv

 

: print out the enviroment variables

 

Example :

 

#printenv

 

XDG_VTNR=7

XDG_SESSION_ID=c1

CLUTTER_IM_MODULE=xim

XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/sharetechnote

SESSION=ubuntu

GPG_AGENT_INFO=/home/jaekuryu/.gnupg/S.gpg-agent:0:1

SHELL=/bin/bash

TERM=xterm-256color

VTE_VERSION=4205

QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1

WINDOWID=56623114

UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1030

GNOME_KEYRING_CONTROL=

GTK_MODULES=gail:atk-bridge:unity-gtk-module

USER=sharetechnote

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:...;36:

QT_ACCESSIBILITY=1

XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0

XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0

SSH_AUTH_SOCK=/run/user/1000/keyring/ssh

DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path

XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg

PATH=/home/sharetechnoe/bin:...:/usr/local/games:/snap/bin

DESKTOP_SESSION=ubuntu

QT_IM_MODULE=ibus

QT_QPA_PLATFORMTHEME=appmenu-qt5

XDG_SESSION_TYPE=x11

PWD=/home/sharetechnote

JOB=unity-settings-daemon

XMODIFIERS=@im=ibus

GNOME_KEYRING_PID=

LANG=en_CA.UTF-8

GDM_LANG=en_CA

MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path

IM_CONFIG_PHASE=1

COMPIZ_CONFIG_PROFILE=ubuntu-lowgfx

GDMSESSION=ubuntu

SESSIONTYPE=gnome-session

GTK2_MODULES=overlay-scrollbar

HOME=/home/sharetechnote

XDG_SEAT=seat0

SHLVL=1

LANGUAGE=en_CA:en

LIBGL_ALWAYS_SOFTWARE=1

GNOME_DESKTOP_SESSION_ID=this-is-deprecated

UPSTART_INSTANCE=

UPSTART_EVENTS=xsession started

XDG_SESSION_DESKTOP=ubuntu

LOGNAME=jaekuryu

COMPIZ_BIN_PATH=/usr/bin/

QT4_IM_MODULE=xim

XDG_DATA_DIRS=/usr/share/ubuntu:...:/var/lib/snapd/desktop

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-e6LwXeFYYa

LESSOPEN=| /usr/bin/lesspipe %s

INSTANCE=

UPSTART_JOB=unity7

XDG_RUNTIME_DIR=/run/user/1000

DISPLAY=:0

XDG_CURRENT_DESKTOP=Unity

GTK_IM_MODULE=ibus

LESSCLOSE=/usr/bin/lesspipe %s %s

XAUTHORITY=/home/sharetechnote/.Xauthority

OLDPWD=/home

_=/usr/bin/env

 

 

 

touch

 

: Create an empty file or multiple files. And you can change some file attributes (e.g, timestamp) with this command.

 

Example :

 

#touch temp.txt

<-- this will create an empty file named temp.txt

 

 

#ls -al

 

drwxrwxr-x  2 sharetechnote sharetechnote 4096 Jan 26 16:51 .

drwxr-xr-x 21 sharetechnote sharetechnote 4096 Jan 26 16:51 ..

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 16:51 temp.txt

                                                                                          <-- See size of the file is 0.

 

 

Example :

 

#touch temp1.txt temp2.txt temp3.txt

<-- this will create three empty files named temp1.txt , temp2.txt and temp3.txt  

 

 

#ls -al

 

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:06 temp1.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:06 temp2.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:06 temp3.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 16:51 temp.txt

 

 

Example :

 

#touch -m temp1.txt

<-- this will update the time stamp for temp1.txt with the current time.

 

 

#ls -al

 

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:09 temp1.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:06 temp2.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 17:06 temp3.txt

-rw-rw-r--  1 sharetechnote sharetechnote    0 Jan 26 16:51 temp.txt

 

 

 

top

 

: monitor processes and system resource usage (This is similar to the TaskManager in Windows)  

 

 

Example :

 

#top

 

Tasks: 151 total,   1 running, 150 sleeping,   0 stopped,   0 zombie

%Cpu(s):  2.4 us,  0.3 sy,  0.0 ni, 97.0 id,  0.3 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem :  2041572 total,   453092 free,   743648 used,   844832 buff/cache

KiB Swap:  2095100 total,  2095100 free,        0 used.  1110616 avail Mem

 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND      

  859 root      20   0  499476 117240  36352 S  1.0  5.7   0:27.74 Xorg         

 1752 jaekuryu  20   0 1262740 206332  76312 S  1.0 10.1   3:53.14 compiz       

 2020 jaekuryu  20   0  662668  35800  28244 S  1.0  1.8   0:02.24 gnome-termi+

 1409 jaekuryu  20   0  358292   8452   7092 S  0.3  0.4   0:00.51 ibus-daemon  

 1492 jaekuryu  20   0  206972   5316   4828 S  0.3  0.3   0:00.11 at-spi2-reg+

 1680 jaekuryu  20   0  567212  33008  25572 S  0.3  1.6   0:00.59 unity-panel+

 1737 jaekuryu  20   0  659580  26916  21684 S  0.3  1.3   0:00.12 indicator-k+

 2796 root      20   0       0      0      0 S  0.3  0.0   0:00.28 kworker/0:0  

 2809 jaekuryu  20   0   41800   3576   3020 R  0.3  0.2   0:00.08 top          

    1 root      20   0  119696   5756   3908 S  0.0  0.3   0:01.23 systemd      

    2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd     

    4 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H

    6 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 mm_percpu_wq

    7 root      20   0       0      0      0 S  0.0  0.0   0:00.18 ksoftirqd/0  

    8 root      20   0       0      0      0 S  0.0  0.0   0:00.17 rcu_sched    

    9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh       

   10 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0  

jaekuryu  1926  0.0  0.2 271724  4908 ?        Sl   17:13   0:00 /usr/lib/gvfs/g

jaekuryu  1933  0.0  0.4 403644  8864 ?        Sl   17:13   0:00 /usr/lib/gvfs/g

jaekuryu  1943  0.0  0.2 257564  5092 ?        Sl   17:13   0:00 /usr/lib/gvfs/g

jaekuryu  1952  0.0  0.2 259528  4452 ?        Sl   17:13   0:00 /usr/lib/gvfs/g

jaekuryu  1982  0.0  0.4 363700  8388 ?        Sl   17:13   0:00 /usr/lib/gvfs/g

jaekuryu  2020  0.2  1.7 662284 35296 ?        Sl   17:13   0:00 /usr/lib/gnome-

jaekuryu  2026  0.0  0.2  22424  4864 pts/17   Ss   17:13   0:00 bash

jaekuryu  2041  0.0  0.8 498104 16372 ?        Sl   17:13   0:00 zeitgeist-datah

jaekuryu  2048  0.0  0.0   4504   780 ?        S    17:13   0:00 /bin/sh -c /usr

jaekuryu  2055  0.0  0.3 405504  6420 ?        Sl   17:13   0:00 /usr/bin/zeitge

jaekuryu  2063  0.0  0.4 310840  9776 ?        Sl   17:13   0:00 /usr/lib/x86_64

jaekuryu  2109  0.0  1.2 600028 25740 ?        Sl   17:14   0:00 update-notifier

jaekuryu  2131  2.6  6.6 710956 136168 ?       SNl  17:14   0:07 /usr/bin/python

root      2163  0.6  5.1 289900 104272 ?       SNl  17:14   0:01 /usr/bin/python

jaekuryu  2518  0.0  0.4 588856  8808 ?        Sl   17:15   0:00 /usr/lib/x86_64

jaekuryu  2541  0.1  1.5 571996 31096 ?        Sl   17:17   0:00 deja-dup --prom

root      2562  0.0  0.0      0     0 ?        S    17:18   0:00 [kworker/u2:0]

jaekuryu  2564  0.0  0.1  37364  3312 pts/17   R+   17:18   0:00 ps -aux