Linux System commands Essentialsand Basics.pptx

mba1130feb2024 26 views 78 slides Sep 08, 2024
Slide 1
Slide 1 of 78
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69
Slide 70
70
Slide 71
71
Slide 72
72
Slide 73
73
Slide 74
74
Slide 75
75
Slide 76
76
Slide 77
77
Slide 78
78

About This Presentation

Linux


Slide Content

Linux Basics

Linux Introduction

What is Linux Advanced Features of Servers: Clustering Virtualization Cloud Computing Real-time computing Specialized storage

Linux System Architecture Hardware layer  – Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc ) Kernel  – Core component of Operating System, interacts directly with hardware, provides low level services to upper layer components Shell  – An interface to kernel, hiding complexity of kernel’s functions from users. Takes commands from user and executes kernel’s functions Utilities  – Utility programs giving user most of the functionalities of an operating systems

Linux System Architecture

Distros

Linux Directory Structure Linux File System

Print current path and Manual Open the Terminal # pwd (prints the working directory) # man <command> (To display the help for the command) e.g. # man grep # ls ls lists all the files in the current directory

Vi Editor Command Mode Input Mode Last-Line Mode Insert ( i , I) Esc Return : vi Editing modes w to save q to quit wq to save and quit q! to quit without saving

Vi Editor Starting the Vi editor Vi lets you create new files or edit existing files. Command to start Vi : vi Opening an existing file/creating a new file vi filename Press I to get into the Insert Mode and start typing Press Esc to get back to the Command Mode

Vi Editor Last line Mode :q :- Quit the editor :q! :- Quit the editor without saving the changes to the file. : wq :- quit and save :w :- only save To go to a specific line in the file : linenumber

Vi Editor Cutting text d^ Deletes from current cursor position to the beginning of the line d$ Deletes from current cursor position to the end of the line dw Deletes from current cursor position to the end of the word dd – Delete 1 line Ndd Deletes one line from current cursor position. Specify count to delete many lines. Use ‘p’ to paste the lines if required e.g. 5dd - this will delete/cut 5 lines .

Vi Editor Yanking and Pasting yl yank a single character. Specify count to yank more characters yw yank a single word. Specify count to yank more words yy yank a single line. Specify count to yank more lines Nyy N indicates number of lines p paste the text that was either deleted or yanked previously

Vi Editor String Search /pattern : search forward for the pattern ?pattern : search backward for the pattern e.g. /error will find the word ‘error’ in the file. Use ‘n’ to iterate through the search result Undo and Redo Press u in the command mode to undo Press ctrl+r in the command mode to redo

Navigate the file system using cd – change directory cd documents/work/accounting (change to relative path) cd / (change to root partition /) cd .. (change up one level of directory) cd ~ (change to current user’s home directory) Create a Directory using mkdir mkdir newdir mkdir –p /root/ newdir /subdir Linux File System

To create an empty (zero byte) file: $ touch filename To create multiple such files: $ touch file1 file2 file3 $ touch file{1..5}. sh Touch Command

Cat # cat filename - It allows to view the contents of a file #cat file1 > file2 > redirect and overwrite >> redirect and append Files and Directory

# less filename (To view a file one page at a time) # more filename (To view a file one page at a time) # tac filename (To view files in a reverse order) Press q to quit #cmd1 | cmd2 | cmd3 This will execute as follows : --> cmd1 --> cmd2 <o/p_cmd1> --> cmd3 <o/p_cmd2> Files and Directory

Copy and Move Files Copy files from source to destination cp source destination e.g. cp sample.txt /home/training/ cp –r sourcefolder destinationfolder Move files from source to destination – cut and paste mv source destination e.g. mv sample.txt /home/training

Copy and Move Files i -- interactive. Prompts you to confirm if the file is going to overwrite a file in your destination. This is a handy option because it can help prevent you from making mistakes. -r -- recursive. Rather than just copying all the files and directories, copies the whole directory tree, subdirectories and all, to another location. -f -- force. Copies without prompting you for confirmation that the file should be overwritten. Unless you're sure you want to force the copy, you probably don't want to make friends with this option right now. -v - verbose. Will show the progress of the files being copied.

Remove # rm filename (To delete a file) # rm file1 file2 file3 (To delete multiple files) # rmdir dirname (To delete a empty folder only) # rm -rfv foldername (To delete a folder & it's content recursively & with verbose) -r = recursive -f = forcefully -v = Verbose

Identifying file type ls -l shows the file type in the 1st character of line. For example. # ls -l /dev - rw - rw ----. 1 root disk 8, 0 Mar 16 08:03 / dev / sda i > Regular Files These are normal files. (represented as '-' in ls -l o/p ) ii> Directory files These are directories. (represented as 'd' in ls -l o/p ) iii> Link Files (Symlinks) This are links(shortcut) . (represented as 'l' in ls -l o/p )

Identifying file type There are 2 types of device files . iv> Character Files (represented as 'c' in ls -l o/p ) Kernel communicates with these devices in character size data (1byte). v> Block Files (represented as 'b' in ls -l o/p ) Kernel communicates with these devices in block size data (512byte). vi> Socket Files (represented as 's' in ls -l o/p Used for communication . vii> Pipe Files (represented as 'p' in ls -l o/p )

Identifying file type # file filename (To Determine the file type) # stat filename (To display file or file system status)

Date, hwclock, calendar # date (To to show current date & time) # date -s 12:00 (To change time) # date -s YYYY-MM-DD (To change date) # date MMDDhhmmYYYY (To change time & date together) MM - Month DD - date hh - hours mm - minute YY - years

26 Head, Tail and Word Count 26 # head filename (To read top 10 lines from a file) # head -n 15 filename (To read top 15 lines from a file) # tail filename (To read bottom 10 lines from a file) # tail -n 15 filename (To read bottom 15 lines from a file) # tail -f / var /log/message (This is will continuously show updates from the file until you pressed ` Ctrl+c ' # wc filename (print the number of newlines, words, and bytes in files)

grep grep --> general regular expression processor Syntax: # grep searchpattern filename # grep error / var /log/syslog # grep bash /etc/ passwd (To search a bash word in a file) -v --> returns lines do not contain the pattern -n --> precede returned lines with line numbers -c --> only return a count of lines with the matching pattern -r --> perform a recursive search of files, starting with the named directory -l --> Use along with “-r” , only returns the names of files that have at least one line containing the pattern -w --> Display only lines having the exact search pattern - i --> perform a case-insensitive search grep

# grep -r useradd / # grep -rli useradd /root/ samnotes # grep -E "word1|word2|word3|word4" /etc/ passwd (To search two or more than two words by using grep) # egrep "bash|nologin" /etc/ passwd (To search two or more than two words by using grep) grep

29 grep Anchors match the beginning or end of a line or word ^ --> Line begins with $ --> Line ends with \ --> Escape Character \ bc --> word begins with ‘c’ c\b --> word ends with ‘c’ \b is a regular expression to indicate any word e.g. $ grep -E “\ ba ” file1 This is a rjun A is for a pple $ ls -al | grep ^d (It will list only Directories)

Display Number of Lines Before or After Search String Another couple of options are the –A and –B switches, which displays the matched line and number of lines either that come before or after the search string. # ifconfig | grep –A 4 eth0 # ifconfig | grep -B 2 UP grep

grep 31 Pipe output to grep #service sshd start # netstat -a | grep 22 There are different types of data:- # ls -al | grep ^- (It will list only Normal files) # ls -al | grep ^d (It will list only Directories) # ls -al | grep ^c (It will list only Character files)

# ls -al | grep ^- | wc -l (It will list only normal files & will count no. of files) #ls –l | grep .txt$ Note : - We can use grep along with color by using following options. # ls -al | grep -- color =always ^- grep

Type ls –l <filename/ dirname > to check the permissions Default file permission for the super user --------------------------------------------- rwx ----> owner/user who is created the file or dir rx ----> group to which owner belongs to rx ----> other people r----> read --->4 w----> write --->2 x----> execute --->1 drwx r-x r-x ------>755---->default permission of directory U G O - rw -r--r----> 644----> default permission of file File Permission

File Permission File permissions are assigned to: 1. the owner of a file 2. the members of the group the file is assigned to 3. all other users 4. Permissions under Linux are configured for each file and directory.

There are three levels of permissions: 1. The permissions that apply to the owner of the file. The owner of a file is by default the user that created the file1. 2. The permissions that apply to all members of the group that is associated with the file. 3. The permissions that apply to all other users on the system. 4. Permissions can only be changed by the owner, and root of course. File Permission

File permission for the normal user rwxrwxr -x ----->4+2+1 4+2+1 4+1----->775----default permission of directory - rw - rw -r-- ---->4+2 4+2 4 ----->664---->default permission of a file File Permission

read = 4 write = 2 execute= 1 chmod 777 <file>/<directory> chmod u= rwx,g = rwx,o = rwx <file>/<directory> chmod g- w,o -w <file>/<directory> chmod u+x <file>/<directory> File Permission

= overwrite - remove + append chmod ugo = rwx perm OR chmod a= rwx perm File Permission

Changing ownership of folder or file chown owner <file/folder> chown sam backup Note :- In above example sam is an owner of backup folder chown owner.groupowner <file/folder> chown owner:groupowner <file/folder> chown sameer.sameer backup chown sameer:sameer backup Changing group ownership of folder or file chgrp grpname <file/folder> chgrp sam backup File Permission

Exercise Create 2 folders under / Create 4 users and 2 groups Map users 1,2 to group 1 and users 3,4 to group 2 User 1 should be able to read,execute and write files in both folders. Group 2 must be able read,execute and write in folder 2. All others have read and execute only permission for both folders.

DF The df (disk free) program shows you the size, used space, and free space on a given disk partition # df –h displays the result in human readable format du Displays the amout of Disk Usage for the specified files and folders e.g. # du folder1 Show the size of specific files/directory $du –h file1 file2 $du –h directory List the sizes of all files inside the directory $du –a directory Free Free show the Memory statistic like the RAM free space # free Disks and Filesystems

Fdisk The fdisk command is a text-based utility for viewing and managing hard disk partitions on Linux. List Partitions # fdisk -l commands lists the partitions on your system. Entering Command Mode To work on a disk’s partitions, you have to enter command mode. You’ll need the device name of a disk from the fdisk -l command. The following command enters command mode for the first disk device: # fdisk /dev/ sda Using Command Mode In command mode, you use single-letter commands to specify actions you want to take. Type m and press Enter to see a list of the commands you can use. Disks and Filesystems

Using fdisk to create a new partition: Type n for creating a new partition Type p for primary partition Type 1 for choosing the partition number Give default for first sector and + sizeM (e.g. +500M) for last sector Type w to save changes Use fdisk –l to see the partition Disks and Filesystems

Formatting a Partition You must format new partitions with a file system before you can use them. You can do this with the appropriate mkfs command. For example, this command formats the fifth partition on the first disk with the ext4 file system. mkfs.ext4 /dev/sda5 Disks and Filesystems

mount mount [options] device directory The mount command makes a partition accessible. Most commonly it handles disk drives (say, /dev/sda1) and removal media (e.g., USB keys), making them accessible via an existing directory (say, / mnt / mydir ): # mkdir / mnt / mydir # ls / mnt / mydir # mount /dev/sda1 / mnt / mydir # ls / mnt / mydir # df / mnt / mydir Or # df -h Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 1011928 285744 674780 30% / mnt / mydir Disks and Filesystems

umount umount [options] [device | directory] umount does the opposite of mount: it makes a disk partition unavailable via the filesystem. For instance, if you’ve mounted a CD-ROM disc, you can’t eject it until it’s umounted : $ umount /media/ cdrom Always unmount a removable medium before ejecting it or you risk damage to its filesystem. To unmount all mounted devices: # umount -a Don’t unmount a filesystem that’s in use; in fact, the umount command will refuse to do so for safety reasons. Disks and Filesystems

FSTAB / etc / fstab file is used to control what file systems are mounted when the system boots, as well as to supply default values for other file systems that may be mounted manually from time to time

1st Column : ~~~~~~~~~~ The first column contains the partitions's label, eg. "LABEL=/boot" or driver's path, eg. "/ dev / cdrom ". Device driver's path tells the system to mount the device with the mentioned device driver. 2nd Column : ~~~~~~~~~~ The second field ( fs_file ) describes the mount point for the filesystem.For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces these can be escaped as `\040'. FSTAB

3rd Column : ~~~~~~~~~~ The third column in the file specifies the file system type of the device or partition. Many diffrent file systems are supported by Linux and most common ones are, 1) autofs 2) devpts 3) ext2 4) ext3 5) iso9660 6) nfs 7) Ntfs 8) proc 9) swap FSTAB

10) tmpfs 11) udf 12) ufs 13) vfat 14) xfs If you are not sure of the file system type of the device then set the value to "auto" and the system will itself determine the file system type andwill mount the device with that file system. FSTAB

4th Column : ~~~~~~~~~~ The fourth column is for permissions to be given to the partition at the time of booting. There are many options which constitutes the forth column. They are as follows : - 1) ro - Read Only 2) rw - Read Write 3) auto - Mount on startup 4) noauto - Do not mount on startup 5) user - Any user can mount, but only unmount device mounted by him 6) nouser - Only root can mount & unmount the device 7) users - Every user can mount and also unmount the device mounted by others 8) owner - Same as user (above no. 5) FSTAB

9) dev - User can use device driver to mount the device 10) nodev - User cannot use device driver to mount the device 11) exec - Users can execute binaries on the partition 12) noexec - Users cannot execute binaries on the partition 13) async - Asynchronous, whenever a file is saved it will be first saved in the RAM and after 30 seconds all the queued files will be written on the hard disk 14) sync - Synchronous, whenever a file is saved it will be directly written to the hard disk 15) suid - Allow set-user-identifier for the device where users are allowed to run binaries even though they do not have execute permissions. 16) nosuid - Do not allow set-user-identifier 17) auto, rw , dev , async , suid , exec & nouser FSTAB

5th Column : ~~~~~~~~~~ The 5th column is for backup option. This column contains either 0 or Where "0" stands for "NO" and "1" stands for "YES". 6th Column : ~~~~~~~~~~ The 6th column is for " fsck " option. fsck stands for file system check. This column defines the order in which the system should scan the partitions on start up. FSTAB

54 54 Performance Monitoring Viewing Processes ps ps [options] The ps command displays information about your running processes, and optionally the processes of other users. Type the following to see every process in the system $ ps - ef To view your processes: $ ps - ux ps -U smith - display processes of user Smith you can extract information more finely from the output of ps using grep and other filter programs: $ ps - ux | grep myprogram

55 55 Performance Monitoring top top [options] The top command lets you monitor the most active processes, updating the display at regular intervals (say, every second). It is a screen-based program that updates the display in place, interactively. $ top While top is running, you can press keys to change its behavior , such as setting the update speed (s), hiding idle processes ( i ), or killing processes (k). Type h to see a complete list and q to quit . Useful options - nN Perform N updates, then quit. - dN Update the display every N seconds. - pN - pM ... Display only the processes with PID N, M, ..., up to 20 processes. -b Print on standard output noninteractively , without playing screen tricks. #top -b -n1 > outfile saves a quick snapshot to a file.

56 56 Performance Monitoring kill [options] [ process_ids ] The kill command sends a signal to a process. This can terminate a process (the default action), interrupt it, suspend it, crash it, and so on. You must own the process, or be the superuser , to affect it. To terminate process 13243, for example, run: $ kill 13243 If this does not work—some programs catch this signal without terminating—add the -KILL or (equivalently) -9 option: $ kill -9 13243

YUM # yum install <package name> Will install the package # yum install \* --> This will install everything # yum update To update all packages # yum update <package name> ----> To update selected package # yum provides < file_path > --->> Shows which package provides that file. # yum clean all --->> To clean all packages in yum cache # yum remove <package name – this will remove package specified # yum -y remove *.* ---> this will remove everything # yum list nfs * ---> this will list package details # yum list all --> To list all packages available # yum info | grep jdk This will list all packages available in repo that have the keyword jdk # yum grouplist # yum groupinstall < group_name > vim / etc / yum.conf :

Red Hat Package Manager RPM stands for  R ed Hat  P ackage  M anager. Installing a RPM package Using rpm –ivh RPM filename has packagename, version, release and architecture name. For example, In the MySQL-client-3.23.57-1.i386.rpm file: MySQL-client – Package Name 3.23.57 – Version 1 – Release i386 – Architecture

Red Hat Package Manager # rpm - ivh MySQL-client-3.23.57-1.i386.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### [100%] rpm command and options -i : install a package -v : verbose -h : print hash marks as the package archive is unpacked.

Red Hat Package Manager 2. Query all the RPM Packages using rpm – qa You can use rpm command to query all the packages installed in your system. # rpm - qa cdrecord-2.01-10.7.el5 bluez-libs-3.7-1.1 setarch-2.0-1.1 . . -q query operation -a queries all installed packages

Red Hat Package Manager To identify whether a particular rpm package is installed on your system # rpm -qa | grep ' cdrecord ‘ 3. Query a Particular RPM Package using rpm –q # rpm -q MySQL-client MySQL-client-3.23.57-1 # rpm -q MySQL package MySQL is not installed

Red Hat Package Manager 4. Query RPM Packages in a various format using rpm – queryformat # rpm -qa --queryformat '%{name-%{version}-%{release} %{size}\n' cdrecord-2.01-10.7 12324 bluez-libs-3.7-1.1 5634 setarch-2.0-1.1 235563 . . # 5. Which RPM package does a file belong to? – Use rpm – qf # rpm - qf / usr /bin/ mysqlaccess MySQL-client-3.23.57-1 -f : file name

Red Hat Package Manager 6. Information about Installed RPM Package using rpm –qi # rpm -qi MySQL-client Name : MySQL-client Relocations: (not relocatable ) Version : 3.23.57 Vendor: MySQL AB Release : 1 Build Date: Mon 09 Jun 2003 11:08:28 PM CEST Install Date: Mon 06 Feb 2010 03:19:16 AM PST Build Host: build.mysql.com Group : Applications/Databases Source RPM: MySQL-3.23.57-1.src.rpm Size : 5305109 License: GPL / LGPL Signature : (none) Packager : Lenz Grimmer URL : http://www.mysql.com/ Summary : MySQL - Client Description : This package contains the standard MySQL clients.

Red Hat Package Manager 7. List the Dependency Packages using rpm – qRP # rpm -qRp MySQL-client-3.23.57-1.i386.rpm /bin/ sh / usr /bin/ perl 8. Upgrading a RPM Package using rpm –Uvh # rpm -Uvh MySQL-client-3.23.57-1.i386.rpm Preparing... ########################################### [100%] 1:MySQL-client ########################################### 9. Uninstalling a RPM Package using rpm –e # rpm -ev MySQL-client

Services # apt-get install –y apache2 # service apache2 start # service apache2 status # service apache2 restart # service apache2 stop # service –-status-all # systemctl start SERVICE - Use it to start a service. Does not persist after reboot # systemctl stop SERVICE - Use it to stop a service. Does not persist after reboot # systemctl restart SERVICE - Use it to restart a service # systemctl status SERVICE - Shows the status of a service. Tells whether a service is currently running. # systemctl enable SERVICE - Turns the service on, on the next reboot or on the next start event. It persists after reboot. # systemctl disable SERVICE

66 66 IP Addressing To check the IP Address # ifconfig <name of interface> or just ifconfig Or # ip a For temporary ip address assignment: # sudo ifconfig <name of interface> 10.9.49.112 netmask 255.255.255.0 e.g. # ifconfig eth0 10.9.49.112 netmask 255.255.255.0 To disable a network interface: ifconfig <name of interface> down To enable a network interface Ifconfig <name of interface> up

67 67 IP Addressing To configure a default gateway, you can use the route command in the following manner. sudo route add default gw 10.0.0.1 <name of interface> Check the default gateway configuration using router command route –n Edit / etc / resolv.conf for assigning temporary dns servers nameserver 8.8.8.8 nameserver 4.2.2.1 To purge all ip configuration Ip a flush <name of interface> # ifdown <name of interface> # ifup <name of interface>

68 68 IP Addressing For permanent IP Address assignment, edit / etc /network/interfaces iface <name of interface> inet static address 192.168.3.3 netmask 255.255.255.0 gateway 192.168.3.1 dnssearch example.com sales.example.com dev.example.com dnsnameservers 192.168.3.45 192.168.8.10 # ifdown <name of interface> # ip a flush <name of interface> # ifup <name of interface> To change back to a dhcp client iface <name of interface> inet dhcp To renew the dhcp client IP # dhclient For adding host names, edit / etc /hosts

69 69 IP Addressing For permanent IP Address assignment in CentOS, edit vi / etc / sysconfig /network-scripts/ifcfg-enp0s3 HWADDR=08:00:27:98:06:76 TYPE=Ethernet # Static IP Address # BOOTPROTO=none IPADDR=192.168.1.10 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=192.168.1.1 DNS2=8.8.8.8 # ifdown <name of interface> # ip a flush <name of interface> # ifup <name of interface>

Lsof – List Open Files Lsof command used in many Linux/Unix like system that is used to display list of all the open files and the processes. The open files included are disk files, network sockets, pipes, devices and processes.

Lsof – List Open Files In the below example, it will show long listing of open files some of them are extracted for better understanding which displays the columns like Command, PID, USER, FD, TYPE  etc . FD  – stands for File descriptor and may seen some of the values as: cwd  current working directory rtd  root directory txt  program text (code and data) mem  memory-mapped file Also in FD column numbers like 1u is actual file descriptor and followed by u,r,w of it’s mode as: r for read access. w for write access. u for read and write access. TYPE  – of files and it’s identification. DIR  – Directory REG  – Regular file CHR  – Character special file. FIFO  – First In First Out

Lsof – List Open Files To display list of all open files with the user ‘training’: # lsof –u training Find processes using specific port number 22 # lsof – i TCP:22 List all connections # lsof - i List all open files of specific device # lsof /dev/sda1 Exclude User with ‘^’ Character # lsof – i – u^root Find the commands used by specific user # lsof – i –u training List open files of specific file system (/proc) # lsof /proc List all files opened by specific process id # lsof –p 12434

Tcpdump – Network Packet Analyzer Tcpdump one of the most widely used command-line network packet analyzer or packets sniffer program that is used capture or filter TCP/IP packets that received or transferred on a specific interface over a network.

Netstat – Network Statistics Netstat is a command line tool for monitoring incoming and outgoing network packets statistics as well as interface statistics. It is very useful tool for every system administrator to monitor network performance and troubleshoot network related problems

Network Commands ssh [options] host [command] The ssh (Secure Shell) program securely logs you into a remote machine where you already have an account: $ ssh remote.example.com Alternatively, it can invoke a program on that remote machine without logging you in: $ ssh remote.example.com who $ ssh [email protected] specify the user smith while connecting

Network Commands scp local_spec remote_spec The scp (secure copy) command copies files and directories from one computer to another in batch. It encrypts all communication between the two machines. As a simple example, scp can copy a local file to a remote machine: $ scp myfile remote.example.com:newfile recursively copy a directory to a remote machine: $ scp -r mydir remote.example.com: copy a remote file to your local machine: $ scp remote.example.com:myfile . or recursively copy a remote directory to your local machine: $ scp -r remote.example.com:mydir . ‘.’ in the above 2 examples indicates that the destination folder in the local machine is the current folder

Run Levels A runlevel is a preset operating state on a Unix-like operating system. A system can be booted into (i.e., started up into) any of several runlevels , each of which is represented by a single digit integer. Each runlevel designates a different system configuration and allows access to a different combination of processes (i.e., instances of executing programs). The are differences in the runlevels according to the operating system. Seven runlevels are supported in the standard Linux kernel (i.e., core of the operating system). They are: 0 - System halt; no activity, the system can be safely powered down. 1 - Single user; rarely used. 2 - Multiple users, no NFS (network filesystem ); also used rarely. 3 - Multiple users, command line (i.e., all-text mode) interface; the standard runlevel for most Linux-based server hardware. 4 - User-definable 5 - Multiple users, GUI (graphical user interface); the standard runlevel for most Linux-based desktop systems. 6 - Reboot; used when restarting the system. By default Linux boots either to runlevel 3 or to runlevel 5. The former permits the system to run all services except for a GUI. The latter allows all services including a GUI. In addition to the standard runlevels , users can modify the preset runlevels or even create new ones if desired. Runlevels 2 and 4 are usually used for user defined runlevels .

Boot and Shutdown $ init 0 - shutdown $ init 6 -restart $ sudo shutdown -h 09:30 "Going down for scheduled maintenance. Expected downtime is 1 hour.“ h stands for Halt $ sudo shutdown –r r is for Restart
Tags