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
-
useradd:
- Adds a new user to the system.
sudo useradd username
-
passwd:
- Changes the password for a user.
sudo passwd username
-
userdel:
- Deletes a user account.
sudo userdel username
-
usermod:
- Modifies user account properties.
sudo usermod options username
-
id:
- Displays user and group information for a specified username.
id username
-
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:
-
Changing the Username:
sudo usermod -l newusername oldusername
-
Changing the User ID (UID):
sudo usermod -u newuid username
-
Changing the Home Directory:
sudo usermod -d /new/home/directory username
-
Changing the Default Shell:
sudo usermod -s /path/to/new/shell username
-
Adding a Supplementary Group:
sudo usermod -aG newgroup username
-
Locking/Unlocking an Account:
sudo usermod -L username # Lock the account sudo usermod -U username # Unlock the account
-
Expiring a User Account:
sudo usermod -e YYYY-MM-DD username
-
Forcing Password Change on Next Login:
sudo usermod -e 1 username
-
see expire date of user and password:
sudo usermod -l newusername
groups
Here are some common commands related to managing user groups in Linux:
-
groupadd:
- Adds a new group to the system.
sudo groupadd groupname
-
groupdel:
- Deletes a group from the system.
sudo groupdel groupname
-
groupmod:
- Modifies group properties.
sudo groupmod options groupname
-
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
-
groups:
- Displays the groups a user belongs to.
groups username
-
newgrp:
- Switches the primary group.
newgrp groupname
-
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:
-
chown:
- Changes the owner of a file.
sudo chown username:groupname file
-
chgrp:
- Changes the group ownership of a file.
sudo chgrp groupname file
-
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
-
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.
-
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.