A cheatsheet for Linux commands
An encoder and decoder for Base 64 encoding
bash
find -iname "<fileName>"
bash
find -iname "*.<fileExtension>"
bash
cp <file> <destination>
bash
mv <file> <destination>
bash
sudo less /etc/group
bash
getent group groupname
bash
sudo usermod -a -G <username> <groupname>
bash
sudo deluser <username> <groupname>
bash
id -u <username>
bash
userdel [options] <username>
Options | Description |
---|---|
-f | Forcefully delete a user account and also with forceful removal of files |
-r | Deletes user account along with mail spool and userโs home directory |
-z | Deletes SELinux users if they are mapped for the users while deleting user from Linux. |
bash
useradd [options] <username>
Options | Description |
---|---|
-m | Creates user home directory under /home/username |
-u [custom userID] | Creates user with specified custom user id |
-g [loginGroupName] | Assigns user to initial login group. Default login group is the user's username. |
-G [otherGroups] | Adds user to additional groups.sudo useradd -G group1,group2 <username> |
-c [customComment] | Adds a short description for the new usersudo useradd -c "Comment" <username> The comment is saved in /etc/passwd grep <username> /etc/passwd Output: <username>:x :1001:1001:Comment:/home/username:/bin/sh |
-e [YYYY-MM-DD] | Adds account expiry date to usersudo useradd -e 2019-01-22 <username> |
bash
filefrag -e <filePath>
Example:
root@hawkins-national-labratory:/home/eleven/Desktop# filefrag -e ST_Linux_1_0.tar.gz
Filesystem type is: ef53
File size of ST_Linux_1_0.tar.gz is 18707973 (4568 blocks of 4096 bytes)
ext: | logical_offset: | physical_offset: | length: | expected: | flags: |
---|---|---|---|---|---|
0: | 0..4095: | 2529280 .. 2533375: | 4096: | ||
1: | 4096..4567: | 2523136 .. 2523607: | 472: | 2533376: | last,eof |
ST_Linux_1_0.tar.gz: 2 extents found
bash
chage -l <username>
None