Top 10 basic Linux Unix commands

Top 10 basic Linux Unix commands

commands

1. ls command

Feature: list directory contents.

Common Usage example:

– List all files and folder with permission/human readable.

[root@localhost ~]# ls -lah
total 195M
dr-xr-x—. 31 root root 4.0K Mar 24 09:31 .
dr-xr-xr-x. 24 root root 4.0K Mar 24 02:24 ..
-rw——-. 1 root root 2.7K Jan 4 10:47 anaconda-ks.cfg
-rw——-. 1 root root 15K Mar 25 10:53 .bash_history
-rw-r–r–. 1 root root 18 May 20 2009 .bash_logout
-rw-r–r–. 1 root root 176 May 20 2009 .bash_profile
-rw-r–r–. 1 root root 176 Sep 22 2004 .bashrc
drwxr-xr-x. 2 root root 4.0K Jan 4 11:27 .cache
drwxr-xr-x. 4 root root 4.0K Jan 4 04:15 .config
-rw-r–r–. 1 root root 100 Sep 22 2004 .cshrc
drwx——. 3 root root 4.0K Jan 4 04:15 .dbus
drwxr-xr-x. 4 root root 4.0K Jan 13 09:43 Desktop
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Documents
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Downloads
drwx——. 3 root root 4.0K Jan 9 10:33 .dropbox
-rw-r–r–. 1 root root 15K Nov 5 2012 epel-release-6-8.noarch.rpm
-rw-r–r–. 1 root root 15K Nov 5 2012 epel-release-6-8.noarch.rpm.1
-rw-r–r–. 1 root root 15K Nov 5 2012 epel-release-6-8.noarch.rpm.2
-rw——-. 1 root root 16 Jan 4 04:15 .esd_auth
drwx——. 4 root root 4.0K Mar 24 02:27 .gconf
drwx——. 2 root root 4.0K Mar 25 10:22 .gconfd
drwx——. 6 root root 4.0K Jan 15 07:17 .gnome2
drwx——. 2 root root 4.0K Jan 15 07:17 .gnome2_private
drwxr-xr-x. 3 root root 4.0K Jan 4 04:15 .gnote
drwx——. 2 root root 4.0K Mar 24 02:27 .gnupg
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 .gstreamer-0.10
-rw-r–r–. 1 root root 107 Mar 24 02:55 .gtk-bookmarks
dr-x——. 2 root root 0 Mar 24 02:27 .gvfs
-rw——-. 1 root root 3.4K Mar 24 02:27 .ICEauthority
-rw-r–r–. 1 root root 40K Jan 4 10:47 install.log
-rw-r–r–. 1 root root 9.1K Jan 4 10:44 install.log.syslog
-rw-r–r–. 1 root root 3.5M Feb 26 03:03 kamailio-3.3.4-1.1.x86_64.rpm
-rw-r–r–. 1 root root 54K Feb 26 03:03 kamailio-mysql-3.3.4-1.1.x86_64.rpm
drwxr-xr-x. 3 root root 4.0K Jan 4 04:15 .local
drwxr-xr-x. 6 root root 4.0K Jan 5 09:17 lynis-1.3.0
-rw-r–r–. 1 root root 117K Dec 25 2011 lynis-1.3.0.tar.gz
-rwxr-xr-x. 1 root root 122M Dec 27 07:16 ManageEngine_NetFlowAnalyzer_HighPerf_9800_64bit.bin
-rwxr-xr-x. 1 root root 69M Dec 29 03:59 ManageEngine_OpManager_64bit.bin
drwxr-xr-x. 4 root root 4.0K Jan 15 07:17 .mozilla
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Music
-rw——-. 1 root root 299 Mar 19 09:00 .mysql_history
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 .nautilus
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Pictures
drwxr—–. 3 root root 4.0K Jan 4 11:44 .pki
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Public
drwx——. 2 root root 4.0K Jan 4 04:15 .pulse
-rw——-. 1 root root 256 Jan 4 04:15 .pulse-cookie
-rw——-. 1 root root 218 Jan 4 04:16 .recently-used.xbel
-rw——-. 1 root root 1.0K Mar 24 09:31 .rnd
-rw-r–r–. 1 root root 13K Nov 12 2010 rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
-rw-r–r–. 1 root root 13K Nov 12 2010 rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm.1
drwxr-xr-x. 2 root root 4.0K Jan 6 10:39 server
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 .spice-vdagent
drwx——. 2 root root 4.0K Jan 4 04:15 .ssh
-rw-r–r–. 1 root root 129 Dec 3 2004 .tcshrc
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Templates
drwxr-xr-x. 2 root root 4.0K Jan 4 04:15 Videos
-rw-r–r–. 1 root root 1.4K Jan 28 23:25 vpd.properties
-rw-r–r–. 1 root root 246K Jan 28 11:12 wget-log
[root@localhost ~]#

2. cd command

Feature: Change  the  current directory to another.

Common Usage example:

[root@localhost ~]# cd /var
[root@localhost var]#[root@localhost var]# cd ..
[root@localhost /]#[root@localhost /]# cd ~
[root@localhost ~]#

3. pwd command

Feature: print name of current/working directory

Common Usage example:

[root@localhost html]# pwd
/var/www/html
[root@localhost html]#

4. df command

Feature: disk space usage on your system.

Common Usage example:

[root@localhost html]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 3.9G 5.3G 42% /
tmpfs 495M 160K 495M 1% /dev/shm
/dev/sda1 291M 56M 221M 20% /boot
[root@localhost html]#

5. top command

Feature: display top Linux services which consume RAM and CPU.

Common Usage example:

[root@localhost /]# top
top – 03:23:05 up 51 min, 3 users, load average: 0.02, 0.02, 0.00

Tasks: 187 total, 1 running, 186 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.7%sy, 0.0%ni, 98.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1012548k total, 829728k used, 182820k free, 53620k buffers
Swap: 2031608k total, 0k used, 2031608k free, 382916k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
278 root 20 0 0 0 0 S 0.3 0.0 0:01.40 scsi_eh_1
2993 kevin.ng 20 0 398m 15m 12m S 0.3 1.6 0:17.11 vmtoolsd
3523 root 20 0 402m 15m 12m S 0.3 1.6 0:05.88 vmtoolsd
3694 root 20 0 97868 4160 3228 S 0.3 0.4 0:00.25 sshd
4040 root 20 0 15032 1300 952 R 0.3 0.1 0:00.02 top
1 root 20 0 19352 1536 1228 S 0.0 0.2 0:01.69 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:00.15 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/0
7 root 20 0 0 0 0 S 0.0 0.0 0:03.95 events/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper
10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 netns
11 root 20 0 0 0 0 S 0.0 0.0 0:00.00 async/mgr
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 pm

6. rpm command

Feature: install/uninstall a package and manage package/software on Linux System.

Common Usage example:

[root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpm
Preparing… ########################################### [100%]
package epel-release-6-8.noarch is already installed
[root@localhost ~]#[root@localhost ~]# rpm -e remi-release-6-2.el6.remi.noarch

List all packages on Linux System

[root@localhost ~]# rpm -qa

7.  yum command

Feature:  is an interactive, rpm based, package manage and perform system updates, including dependency based on repository.

Common Usage example:

[root@localhost ~]# yum install php-cli
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: virror.hanoilug.org
* epel: ftp.cuhk.edu.hk
* extras: virror.hanoilug.org
* updates: repo.cloudhosting.com.hk
Setting up Install Process
Package php-cli-5.3.3-22.el6.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]#[root@localhost ~]# yum erase php-cli
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package php-cli.x86_64 0:5.3.3-22.el6 will be erased
–> Processing Dependency: php-cli(x86-64) = 5.3.3-22.el6 for package: php-5.3.3 -22.el6.x86_64
–> Running transaction check
—> Package php.x86_64 0:5.3.3-22.el6 will be erased
–> Finished Dependency ResolutionDependencies Resolved================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
php-cli x86_64 5.3.3-22.el6 @base 6.2 M
Removing for dependencies:
php x86_64 5.3.3-22.el6 @base 3.5 MTransaction Summary
================================================================================
Remove 2 Package(s)
Installed size: 9.7 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Erasing : php-5.3.3-22.el6.x86_64 1/2
Erasing : php-cli-5.3.3-22.el6.x86_64 2/2
Verifying : php-cli-5.3.3-22.el6.x86_64 1/2
Verifying : php-5.3.3-22.el6.x86_64 2/2Removed:
php-cli.x86_64 0:5.3.3-22.el6Dependency Removed:
php.x86_64 0:5.3.3-22.el6Complete!
[root@localhost ~]#

8. vi command

Feature: edit text file on Linux System.

Common Usage example:

[root@localhost ~]# vi filetext

9. cat command

Feature: view text file on Linux System.

Common Usage example:

[root@localhost ~]# cat filetext
hello this is text file
[root@localhost ~]#

10. tar command

Feature: using to create tar archive or extract tar archive

Common Usage example:

Create backup.tar file for /var

tar cvf backup.tar /var

Extract a tar file

tar -xzvf backup.tar

That’s all. Thanks for using IThelpblog.com.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>