Post

Linux

Linux

Linux

3 User Catogories

SuperUser Acount User Acount /home/user Service Acount eg. mysql user only for mysql

Permissions

cat /etc/passwd Has registered user z Format USERNAME : PASSWORD : UID : GID : GECOS : HOMEDIR : SHELL

To create a new user : adduser USERNAME

Creating a group

1
sudo groupadd devops
1
cat /etc/
  • adduser
  • addgroup
  • deluser -these all are for interavtive mode and the other is a low level utility where the user shhould gvive alll the necessary information -so the add user can be used interactively while useradd commands can ge userd when automated
    1
    
    usermod -g groupname username
    

    a user can have one primary and multiple secondary groups For primary group use -g and for seconady use -G

  • -G resets all the user secinday groups in order to append the newgroup use -aG
1
usermod -aG sudo <username>

adding a user to the sudo group

File Permissions and Ownership

Ownership

  • Two owners the user and the group
    1
    
    chown USERNAME:GPOUPNAME FILENAME
    
1
 sudo chgrp GROUPNAME FILENAME

d rwx-rwx-rwx Owner (u) - Group (g) - Other (o)

Modyfying file permissions

1
chmod -x api

remove the execcute permisdsion for all the owners

1
chmod g-w FILENAME
1
chmod g=rwx FILENAME

RWX R– RW-

1
chmod 777 FILENAME
   
NumberPermission TypeSymbol
1No Permission–x
2Execute-w-
3Write-wx
4Execute + Writer__
5Readr-x
6Read + Executerwx
7Read +WriteSymbol

Pipeline

using the output of the previous command as the input of the next command

1
cat /var/log/syslog | less
1
history | "grep ls -l"

less is a program that displays large content in good manner

Redirection

1
history > history.txt

redirects the content of the previous commands to a new file

Environment Variables

1
printenv

Setting a env variable

1
export DB_USERNAME = dbuser

Deleting an environment variable

1
unset DB_USERNAME

Persisting an env variable

1
2
3
nano .bashrc

source .bashrc  # used to load the newly added environment variables

Base 64 encoding

1
echo -n 'username' | base64
This post is licensed under CC BY 4.0 by the author.