simple commands

Introduction to LINUX (Basic Commands)

[root@localhost ~]# hostname
localhost.localdomain

[root@localhost ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:63:46:BD
inet addr:172.16.28.145  Bcast:172.16.28.255  Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe63:46bd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:2332 errors:0 dropped:0 overruns:0 frame:0
TX packets:1455 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:257468 (251.4 KiB)  TX bytes:192203 (187.6 KiB)

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:65536  Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:960 (960.0 b)  TX bytes:960 (960.0 b)

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:63:46:bd brd ff:ff:ff:ff:ff:ff
inet 172.16.28.145/24 brd 172.16.28.255 scope global eth0
inet6 fe80::20c:29ff:fe63:46bd/64 scope link
valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
link/ether 42:be:5a:58:ad:92 brd ff:ff:ff:ff:ff:ff

[root@localhost ~]# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
172.16.28.254            ether   00:50:56:ff:aa:b1   C                     eth0
172.16.28.2              ether   00:50:56:e6:ec:2b   C                     eth0
172.16.28.1              ether   00:50:56:c0:00:08   C                     eth0

[root@localhost ~]# logname
root

[root@localhost ~]# who
root     tty1         2016-03-26 20:30 (:0)
root     pts/0        2016-03-26 20:31 (:0.0)
root     pts/1        2016-03-26 20:32 (172.16.28.1)

[root@localhost ~]# who am i
root     pts/1        2016-03-26 20:32 (172.16.28.1)

[root@localhost ~]# whoami
root

[root@localhost ~]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[root@localhost ~]# useradd jack

[root@localhost ~]# passwd jack
Changing password for user jack.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

mohammedrafi@NOC-RAFI:~$ ssh jack@172.16.28.145
jack@172.16.28.145’s password:

[jack@localhost ~]$ whoami
jack
[jack@localhost ~]$ who
root     tty1         2016-03-26 20:30 (:0)
root     pts/0        2016-03-26 20:31 (:0.0)
root     pts/1        2016-03-26 20:32 (172.16.28.1)
jack     pts/2        2016-03-26 21:29 (172.16.28.1)

[jack@localhost ~]$ id
uid=501(jack) gid=501(jack) groups=501(jack) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[jack@localhost ~]$ tty
/dev/pts/2

[root@localhost ~]# w
21:31:45 up  1:04,  4 users,  load average: 0.01, 0.02, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1     :0               20:30    1:04m  4.31s  4.31s /usr/bin/Xorg :0 -br -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-O1LNMm/d
root     pts/0    :0.0             20:31   59:53   0.02s  0.02s /bin/bash
root     pts/1    172.16.28.1      20:32    0.00s  0.32s  0.19s w
jack     pts/2    172.16.28.1      21:29    1:40   0.04s  0.04s -bash

[root@localhost ~]# users
jack root root root

[root@localhost ~]# groups 
root

[root@localhost ~]# tty
/dev/pts/1

[root@localhost ~]# pwd
/root
[root@localhost ~]# mkdir first
[root@localhost ~]# cd first/

[root@localhost first]# mkdir second

[root@localhost first]# cd second/

[root@localhost second]# pwd
/root/first/second

[root@localhost second]# cd ..

[root@localhost ~]# runlevel 
N 5

[root@localhost first]# pwd
/root/first

[root@localhost first]# cd ..

[root@localhost ~]# pwd
/root

[root@localhost ~]# cd first/second/

[root@localhost second]# pwd
/root/first/second

[root@localhost second]# cd

[root@localhost ~]# pwd
/root

[root@localhost ~]# cd first/second/

[root@localhost second]# pwd
/root/first/second

[root@localhost second]# cd ../..

[root@localhost ~]# pwd
/root

[root@localhost ~]# mkdir one/two/three
mkdir: cannot create directory `one/two/three’: No such file or directory

[root@localhost ~]# mkdir -p one/two/three

[root@localhost ~]# cd one/two/three/

[root@localhost three]# pwd
/root/one/two/three

[root@localhost three]# cd

[root@localhost ~]# pwd
/root

[root@localhost ~]# ls
anaconda-ks.cfg  Documents  first        install.log.syslog  one       Public                          Templates
Desktop          Downloads  install.log  Music               Pictures  rhel-server-6.7-x86_64-dvd.iso  Videos

[root@localhost ~]# ls -a
.                .bashrc  Documents  .gnome2          .gvfs               Music      .pulse-cookie
..               .cache   Downloads  .gnome2_private  .ICEauthority       .nautilus  rhel-server-6.7-x86_64-dvd.iso
anaconda-ks.cfg  .config  .esd_auth  .gnote           install.log         one        .ssh
.bash_history    .cshrc   first      .gnupg           install.log.syslog  Pictures   .tcshrc
.bash_logout     .dbus    .gconf     .gstreamer-0.10  .local              Public     Templates
.bash_profile    Desktop  .gconfd    .gtk-bookmarks   .mozilla            .pulse     Videos

[root@localhost ~]# ls -l
total 3752044
-rw——-. 1 root root       3301 Dec 24 00:59 anaconda-ks.cfg
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Desktop
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Documents
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Downloads
drwxr-xr-x. 3 root root       4096 Mar 26 21:34 first
-rw-r–r–. 1 root root      42780 Dec 24 00:59 install.log
-rw-r–r–. 1 root root       9380 Dec 24 00:56 install.log.syslog
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Music
drwxr-xr-x. 3 root root       4096 Mar 26 21:36 one
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Pictures
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Public
-rwxr-xr-x. 1 root root 3841982464 Feb 22 05:22 rhel-server-6.7-x86_64-dvd.iso
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Templates
drwxr-xr-x. 2 root root       4096 Dec 23 19:34 Videos

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-573.el6.x86_64 #1 SMP Wed Jul 1 18:23:37 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# getconf LONG_BIT
64

kernal-name
[root@localhost ~]# uname -s
Linux

hostname
[root@localhost ~]# uname -n
localhost.localdomain

kernal-release
[root@localhost ~]# uname -r
2.6.32-573.el6.x86_64

Machine-hardware name
[root@localhost ~]# uname -m
x86_64

kernal process type
[root@localhost ~]# uname -p
x86_64

Hard-ware platform
[root@localhost ~]# uname -i
x86_64

operating-system
[root@localhost ~]# uname -o
GNU/Linux

[root@localhost ~]# cat /etc/system-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)

[root@localhost ~]# alias x=hostname

[root@localhost ~]# x
localhost.localdomain

[root@localhost ~]# arch 
x86_64

[root@localhost ~]# alias -p
alias cp=’cp -i’
alias l.=’ls -d .* –color=auto’
alias ll=’ls -l –color=auto’
alias ls=’ls –color=auto’
alias mv=’mv -i’
alias rm=’rm -i’
alias which=’alias | /usr/bin/which –tty-only –read-alias –show-dot –show-tilde’
alias x=’hostname’

[root@localhost ~]# unalias x

[root@localhost ~]# x
-bash: x: command not found

[root@localhost ~]# ls
anaconda-ks.cfg  Documents  first        install.log.syslog  one       Public                          Templates
Desktop          Downloads  install.log  Music               Pictures  rhel-server-6.7-x86_64-dvd.iso  Videos

[root@localhost ~]# stat one/
File: `one/’
Size: 4096       Blocks: 8          IO Block: 4096   directory
Device: 803h/2051d Inode: 524591      Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-03-26 21:36:33.823343770 -0700
Modify: 2016-03-26 21:36:13.334344400 -0700
Change: 2016-03-26 21:36:13.334344400 -0700

[root@localhost ~]# stat anaconda-ks.cfg 
File: `anaconda-ks.cfg’
Size: 3301       Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d Inode: 131081      Links: 1
Access: (0600/-rw——-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-12-23 19:38:42.073296687 -0800
Modify: 2015-12-24 00:59:23.445998907 -0800
Change: 2015-12-24 00:59:43.342998933 -0800

[root@localhost ~]# history 

[root@localhost ~]# touch file1

[root@localhost ~]# cat >file1 
hai this is first file

[root@localhost ~]# cat file1 
hai this is first file

[root@localhost ~]# cat >> file1 
this is newly appended

[root@localhost ~]# cat file1 
hai this is first file
this is newly appended

[root@localhost ~]# cat > file1 
it will replace all what is exixting

[root@localhost ~]# cat file1 
it will replace all what is exixting

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        55G  6.2G   46G  12% /
tmpfs           358M   76K  358M   1% /dev/shm
/dev/sda1       283M   41M  228M  16% /boot

[root@localhost ~]# df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda3      ext4    55G  6.2G   46G  12% /
tmpfs          tmpfs  358M   76K  358M   1% /dev/shm
/dev/sda1      ext4   283M   41M  228M  16% /boot

[root@localhost ~]# du /root/one/
4 /root/one/two/three
8 /root/one/two
12 /root/one/

[root@localhost ~]# du -h /root/one/
4.0K /root/one/two/three
8.0K /root/one/two
12K /root/one/

[root@localhost ~]# free 
total       used       free     shared    buffers     cached
Mem:        732388     581172     151216       3380      35732     222480
-/+ buffers/cache:     322960     409428
Swap:      4095996       1932    4094064

[root@localhost ~]# free -m
total       used       free     shared    buffers     cached
Mem:           715        567        147          3         34        217
-/+ buffers/cache:        315        399
Swap:         3999          1       3998

[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/sda2                               partition 4095996 1932 -1

[root@localhost ~]# swapoff -a

[root@localhost ~]# swapon -s
Filename Type Size Used Priority

[root@localhost ~]# swapon -a

[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/sda2                               partition 4095996 0 -1

[root@localhost ~]# lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk
├─sda1   8:1    0  300M  0 part /boot
├─sda2   8:2    0  3.9G  0 part [SWAP]
└─sda3   8:3    0 55.8G  0 part /
sr0     11:0    1 1024M  0 rom

[root@localhost ~]# blkid /dev/sda1
/dev/sda1: UUID=”d5b88247-f67f-4b40-9862-16826e250b78″ TYPE=”ext4″

[root@localhost ~]# blkid /dev/sda2
/dev/sda2: UUID=”af69d0e5-b600-49a0-9228-d4195936bdd2″ TYPE=”swap”

[root@localhost ~]# blkid /dev/sda3
/dev/sda3: UUID=”cbc3eda3-9a23-4943-a8c4-3990addeb161″ TYPE=”ext4″

Advertisements

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 )

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