Advance Linux Commands

Advance Linux Commands

Hello connections,

I'm writing to share my enthusiasm for contributing an Article on "Avance Linux Learning " in #90daysofdevops with #trainwithshubham.In this article I explore some of the day to day used commands and concepts of linux as a #devopsengineer #1stBolg

USER:

* The information of a user is stored in file.

# /etc/passwd

1.How to create a user?

# sudo useradd <username>

2.How to set password of a user?

# sudo passwd <username>

3.Modify User Account.

# sudo usermod -aG <groupname> <username>

4.How to change the user password?

# sudo passwd <username>

Groups:

1.Creating Groups: we can create groups by using following command

?sudo groupadd <groupname>

2. To check the group is created or not:

??cat /etc/group

??getnet group <groupname> - to check details of specific group

3.Modifying group:

?a) changing group name: if we need to modify group name after creating it, command we should use:

???sudo groupmod -n <newgroupname> <oldgroupname>

?b)Adding Users to a Group: To add new user to an existing gruop

???sudo usermod -aG <groupname> <username>

?c) Removing Users from a Group:

???sudo gpasswd -d <groupname> <username>

4. Deleting Groups:

??a) if we want to delete a group then use?

???sudo groupdel <groupname>

Filters:

1. GREP: Global search for regular expression and print out, the grep filter searches a file for a particular pattern of characters, and displays all lines that?contain that pattern.

Syntax: grep [options] pattern [file(s)]

we can use flags like -i for caseinsensitive and -r for recursively search.

2. AWK:(a) Scans a file line by line?

????(b) Splits each input line into fields?

????(c) Compares input line/fields to pattern?

????(d) Performs action(s) on matched lines?

syntax: awk options 'selection _criteria {action }' (input-file name) > (output-file name)

????slection_criteria: specifies the condition to match in the input file.

????action defines the processing to be done when the pattern is matched.

3.Find: It can be used to find files and directories and perform subsequent operations on them

syntax:?

$ find [where to start searching from] [expression determines what to find]

File permissions:?

Linux is a multi-user operating system, so it has security to prevent people from accessing each other’s confidential files.?

First, you must think of those nine characters as three sets of three characters see bellow. Each of the three “rwx” characters refers to a different operation you can?

perform on the file.

---???---???---

rwx???rwx???rwx

user??group??other?


Read, write, and execute.?

Letters Definition

r = “read” the file’s contents.?

w = “write”, or modify, the file’s contents.?

x = “execute” the file. This permission is given only if the file is a program.

The octal notation:

octal = file mode

0???= ---

1???= --x

2???= -w-

3???= -wx

4???= r--

5???= r-x

6???= rw-

7???= rwx

SSH:?

ssh stands for “Secure Shell”. It is a protocol used to securely connect to a remote server/system. ssh is secure in the sense that it transfers the data in encrypted?

form between the host and the client.

TCP/IP Port: 22

Syntax: ssh user_name@host(IP/Domain_name)

How to create public-private keys?

# ssh-keygen

Type of authentication:

Majorly two types of authentication

a)Password-based Authentication

b)Key-based Authentication

?- Public Key:Public key is placed on remote server.

?- Priavte Key: While private key is remains on the local machine.

SCP:?

scp (secure copy protocol) command in Linux system is used to copy file(s) between servers in a secure way.

Options: Optional flags to customize the SCP behavior, such as encryption, preserving file attributes, recursive copy, and more.

Source: Specifies the file or directory you want to copy from the local system or remote system.

Destination: Specifies the location where the files or directories will be copied to, either on the local system or a remote system.

1) If we want to copy a file from a local machine to a remote machine:

syntax: scp [file_name]?remoteuser@remotehost:/remote/directory

whereas,

????file_name = The name of the file that needs to be copied.

????remoteuser =The username of the remote host.

????remotehost = The IP address or hostname of the remote host.

????/remote/directory = The directory where the file should be copied on the remote machine.

2) If we want to copy a file from remote machine to our local machine.

syntax: scp user@remotehost:/home/user/file_name.

whereas,

????user = username of remote system.

????remotehost = IP address of remote system.

????/home/user/file_name = path of file that has to be copied.

????“.” = this means that we are copying that file in current location in local system.

Systemctl: The systemctl command is a critical tool used in modern Linux distributions to manage the systemd system and service manager.

Start a Service:

?????syntax: systemctl start <service_name>

????Stop a Service:

????System: systemctl stop <service_name>

?????Restart a Service:

?????Syntax: systemctl restart <service_name>

Shubham Londhe TrainWithShubham #day05 #90daysofdevops #linux

#devopsengineer #devopsjourney






要查看或添加评论,请登录

社区洞察

其他会员也浏览了