Powered By Blogger

Aug 6, 2024

Operating System Lab Practical-08

 

Practical 08

Title : Linux Commands for System Administrators

_________________________________________________________________________________


Linux System Administrator involves the installation, configuration, maintenance and management of Linux-based systems.

1. Uptime Command

The Linux uptime command shows how long your system is running and the number of users who are currently logged in and also displays the load average of a system for 1, 5, and 15 minutes intervals.

# uptime

08:16:26 up 22 min,  1 user,  load average: 0.00, 0.03, 0.22

  • Check Uptime Version

Uptime command don’t have other options other than uptime and version. It gives information only in hours:mins:sec if it is less than 1 day.

# uptime -V

procps version 3.2.8

2. W Command

The w command will display users currently logged in and their process along with showing load averages, login name, tty name, remote host, login time, idle time, JCPU, PCPU, command, and processes.

# w

08:27:44 up 34 min,  1 user,  load average: 0.00, 0.00, 0.08                                                            USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT                                tecmint  pts/0    192.168.50.1     07:59    0.00s  0.29s  0.09s w

  • Available Options

  • -h : displays no header entries.

  • -s : without JCPU and PCPU.

  • -f : Removes from the field.

  • -V : (upper letter) – Shows versions.

3. Users Command

Users command displays currently logged-in users. This command doesn’t have other parameters other than help and version.

# users

tecmint

4. Who Command

Who command returns the user name, date, time, and host information. who command is similar to w command. Unlike the w command who doesn’t print what users are doing. Let’s illustrate and see the difference between who and w commands.

# who

tecmint  pts/0        2012-09-18 07:59 (192.168.50.1)


# w

08:43:58 up 50 min,  1 user,  load average: 0.64, 0.18, 0.06

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT

tecmint  pts/0    192.168.50.1     07:59    0.00s  0.43s  0.10s w

  • Who command Options

    • -b: Displays last system reboot date and time.

    • -r: Shows current runlet.

    • -a, –all: Displays all information cumulatively.

5. ls Command

Ls command displays a list of files in a human-readable format.

# ls -l

total 114

dr-xr-xr-x.   2 root root  4096 Sep 18 08:46 bin

dr-xr-xr-x.   5 root root  1024 Sep  8 15:49 boot

Sort file as per last modified time.




# ls -ltr

total 40

-rw-r--r--. 1 root root  6546 Sep 17 18:42 install.log.syslog

-rw-r--r--. 1 root root 22435 Sep 17 18:45 install.log

-rw-------. 1 root root  1003 Sep 17 18:45 anaconda-ks.cfg

6. Crontab Command

List scheduled jobs for current users with crontab command and -l option.

# crontab -l
00 10 * * * /bin/ls >/ls.txt

Edit your crontab with -e the option. The below example will open scheduled jobs in VI editor. Make necessary changes and quit pressing :wq keys that save the setting automatically.

# crontab -e

7. Less Command

less command allows quickly viewing the file. You can page up and down. Press ‘q‘ to quit from less window.

# less install.log


Installing setup-2.8.14-10.el6.noarch

warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

Installing filesystem-2.4.30-2.1.el6.i686

Installing ca-certificates-2010.63-3.el6.noarch

Installing xml-common-0.6.3-32.el6.noarch

Installing tzdata-2010l-1.el6.noarch

Installing iso-codes-3.16-2.el6.noarch

8. More Command

more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.

# more install.log


Installing setup-2.8.14-10.el6.noarch

warning: setup-2.8.14-10.el6.noarch: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY

Installing filesystem-2.4.30-2.1.el6.i686

Installing ca-certificates-2010.63-3.el6.noarch

Installing xml-common-0.6.3-32.el6.noarch

Installing tzdata-2010l-1.el6.noarch

Installing iso-codes-3.16-2.el6.noarch

--More--(10%)

9. SSH Command (Secure Shell)


SSH command is used to login into the remote host. For example, the below ssh command will connect to the remote host (192.168.50.2) using the user as Narad.


# ssh 

narad@192.168.50.2

10. ps command


The ps command displays processes running in the system. The below example show the init to process only.


# ps -ef | grep init


root         1     0  0 07:53 ?        00:00:04 /sbin/init

root      7508  6825  0 11:48 pts/1    00:00:00 grep init

11. Systemctl Command

Systemctl command is a systemd management tool that is used to manage services, check running statuses, start and enable services and work with the configuration files.

# systemctl start httpd.service             # systemctl enable httpd.service                                                                 # systemctl status httpd.service

12. kill command

Use the kill command to terminate the process. First, find process id with ps command as shown below and kill the process with kill -9 command.

# ps -ef | grep init

root         1     0  0 07:53 ?        00:00:04 /sbin/init

root      7508  6825  0 11:48 pts/1    00:00:00 grep init


# kill- 9 7508





No comments:

Post a Comment

Featured Post

Data Analysis

    What is data analysis and its significance?   Data analysis is the process of collecting, transforming, and organizing data to dr...

Popular Posts