ob-vaults/Phoenix/az_system/commands.md
2024-09-12 17:54:01 +03:30

4.3 KiB

status: #doc Tags: #linux links: Date: 2023-11-07


linux commands

list

list with details

ls -ltrh

make and destroy

directory

make directory

mkdir

delete directory

rmdir

find command locatiozn

whereis

zip

ziping

for 1 file

zip zipfilename.zip what_to_zip_file  
gzip  zipfilename.zip what_to_zip_file  

for folder

zip -r zipfilename.zip what_to_zip_folder  
gzip -r zipfilename.zip what_to_zip_folder  

unzip

unzip
gunzip

user mangmet

user

  • see encrypted users password
cat etc/shadow
  1. useradd:

    • Adds a new user to the system.
    sudo useradd username
    
  2. passwd:

    • Changes the password for a user.
    sudo passwd username
    
  3. userdel:

    • Deletes a user account.
    sudo userdel username
    
  4. usermod:

    • Modifies user account properties.
    sudo usermod options username
    
  5. id:

    • Displays user and group information for a specified username.
    id username
    
  6. passwd -e:

    • Expire a user's password immediately, forcing them to change it on the next login.
    sudo passwd -e username
    

usermod options

Certainly! Here's the text with the content changed to a numbered list:

  1. Changing the Username:

    sudo usermod -l newusername oldusername
    
  2. Changing the User ID (UID):

    sudo usermod -u newuid username
    
  3. Changing the Home Directory:

    sudo usermod -d /new/home/directory username
    
  4. Changing the Default Shell:

    sudo usermod -s /path/to/new/shell username
    
  5. Adding a Supplementary Group:

    sudo usermod -aG newgroup username
    
  6. Locking/Unlocking an Account:

    sudo usermod -L username   # Lock the account
    sudo usermod -U username   # Unlock the account
    
  7. Expiring a User Account:

    sudo usermod -e YYYY-MM-DD username
    
  8. Forcing Password Change on Next Login:

    sudo usermod -e 1 username
    
  9. see expire date of user and password:

    sudo usermod -l newusername 
    

groups

Here are some common commands related to managing user groups in Linux:

  1. groupadd:

    • Adds a new group to the system.
    sudo groupadd groupname
    
  2. groupdel:

    • Deletes a group from the system.
    sudo groupdel groupname
    
  3. groupmod:

    • Modifies group properties.
    sudo groupmod options groupname
    
  4. gpasswd:

    • Adds or removes users from a group.
    sudo gpasswd -a username groupname  # Add user to group
    sudo gpasswd -d username groupname  # Remove user from group
    
  5. groups:

    • Displays the groups a user belongs to.
    groups username
    
  6. newgrp:

    • Switches the primary group.
    newgrp groupname
    
  7. getent group:

    • Displays information about groups from the system databases and Name Service Switch sources.
    getent group
    

file

Managing file ownership and permissions is an important aspect of user management in Linux. Here are some commands related to user management for files:

  1. chown:

    • Changes the owner of a file.
    sudo chown username:groupname file
    
  2. chgrp:

    • Changes the group ownership of a file.
    sudo chgrp groupname file
    
  3. chmod:

    • Changes the permissions of a file.
    sudo chmod permissions file
    

    The permissions can be represented in octal or symbolic notation. For example:

    sudo chmod 755 file    # Give read, write, and execute to owner; read and execute to group and others
    
  4. ls:

    • Lists files and their permissions.
    ls -l file
    

    Example output:

    -rwxr-xr-x 1 username groupname 1234 Nov 21 12:34 file
    

    The first field represents the file type and permissions.

  5. umask:

    • Sets the default permissions for newly created files.
    umask 022
    

    This example sets the default permissions to rw-r--r-- for newly created files.


References