Linux – System Basic Commands (Faq)

1. How will you check OS architecture?

[sdbt ~]$ arch
x86_64

2. How to print OS kernal information?

This command is mainly used for identifying kernal version for patching / installing RPMs(REDHAT PACKET MANAGER)

[sdbt ~]$ uname -r
3.8.13-44.1.1.el6uek.x86_64

[sdbt ~]$ uname -a
Linux sdbt.localdomain 3.8.13-44.1.1.el6uek.x86_64 #2 SMP Wed Sep 10 06:10:25 PDT 2014 x86_64 x86_64 x86_64 GNU/Linux

3. Print Linux version/release.

[sdbt ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.2 (Santiago)

4. Print Servername

[sdbt ~]$ hostname
sdbt.localdomain

[sdbt ~]$ hostname –i #Display the host ip addresses only
192.168.1.250

5. Print when the linux server started

[sdbt ~]$ uptime
14:56:17 up 4:36, 4 users, load average: 0.65, 0.44, 0.50

6. Print date in 01/01/21 format.

[sdbt ~]$ date +%m/%d/%y
01/01/21

7. Print who are all connected to teh server.

[sdbt ~]$ who
oracle tty1 2018-06-29 10:20 (:0)
oracle pts/0 2018-06-29 14:20 (192.168.1.17)
sdbt pts/1 2018-06-29 14:37 (192.168.1.5)
sdbt pts/2 2018-06-29 15:06 (192.168.1.5)

8. Print user and group details.

[sdbt ~] id
uid=2028(jlaxmi) gid=2028(jlaxmi) groups=2028(jlaxmi),54321(oinstall)

9. Print the command to list out the previous commands ou entered.

[sdbt ~]$ history
1 pwd
2 hostname -i
3 su sdbt
4 pwd
7 date
8 date +%A
9 who am i
10 w
11 who -T
12 wall
13 uptime -V
14 history

10. How to clear the history commands.

[sdbt ~]$ history -c

11. What is use of alias?

Alias is a shortcut for other commands

Ex. Instead of navigating like ‘cd /u01/app/oracle/product/19.3′,
we can create a shotrcut like

[sdbt ~]$ alias hm=’cd /u01/app/oracle/product/19.3’

then just type hm, you can navigate to the above folder from any place.

12. Print how many CPUS

[sdbt ~]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 42
model name : Intel(R) Xeon(R) CPU E31220 @ 3.10GHz
stepping : 7
microcode : 0x29
cpu MHz : 1600.000
cache size : 8192 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 4

or

[sdbt ~]$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
CPU socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 142
Stepping: 10
CPU MHz: 1896.000
BogoMIPS: 3792.00
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 6144K
NUMA node0 CPU(s): 0

13. print memory(RAM) and SWAP information.

[sdbt ~]$ cat /proc/meminfo
MemTotal: 7620288 kB
MemFree: 624548 kB
Buffers: 156812 kB
Cached: 5610244 kB
SwapCached: 0 kB
Active: 3907708 kB
Inactive: 2731372 kB
Active(anon): 2927820 kB
Inactive(anon): 809092 kB
Active(file): 979888 kB
Inactive(file): 1922280 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 31457276 kB
SwapFree: 31457276 kB

14. how to add two numbers.

[sdbt ~]$ expr 10 + 40
50