Permission number (octal mode)
User | Group | Other
Permission Set | Octal value |
---|---|
— | 0 |
–x | 1 |
-w- | 2 |
-wx | 3 |
r– | 4 |
r-x | 5 |
rw- | 6 |
rwx | 7 |
Get octal format of myfile permission:
stat -c '%a' myfile
User management
- Could check the count of users in /home directory! but not accurate as differs from distros 🙂
- Manage users via:
/etc/passwd
- First user usually gets UID=1000.
- UIDs <1000 are system user accounts.
- Count number of users:
sudo cat /etc/passwd | wc -l
- Search user michael:
sudo cat /etc/passwd | grep michael
- Add user (with explicit home folder)
sudo adduser -m john
- Ubuntu
sudo adduser --home /home/mika --shell /bin/bash mika
- Remove user with home folder (would depend on retention policy..)
sudo userdel -r john
- Set password for specific user
sudo passwd bill
- System user (for automation/cron) -r
sudo user add -r sysuser
- Passwords in
sudo nano /etc/shadow
User default Shell
- List available shells
cat /etc/shells
- Set shell for new users in:
/etc/default/useradd
- Manually change it /etc/passwd file
sudo nano /etc/passwd
- usermod – (user modifying) eg: /bin/sh to /bin/bash
grep john /etc/passwd
usermod --shell /bin/bash john
- chsh – (change shell) eg: /bin/bash to /bin/sh
grep john /etc/passwd
chsh --shell /bin/sh john
Links (symbolic & hard)
- link object to another
- inode (ls -i): data object that contains metadata about the files (incl. size, owner, permission string..)
ln -
Trash location
/home/$USER/.local/share/Trash
/home/ubuntu/.local/share/Trash
sudo cd /root/.local/share/Trash
scp
Secure Copy Protocol – copy files/folders:
- between local host and remote host
- between 2 remote hosts
sudo scp -i /home/ubuntu/mikado/Keypair.pem -r /home/ubuntu/mikado ubuntu@1.2.3.4:/home/ubuntu/mikado
File
Copy file from local to a host
scp file.txt username@to_host:/remote/directory/
Copy file from remote to local
scp username@from_host:file.txt /local/directory/
Directory
Copy directory from local to remote
scp -r /local/directory/ username@to_host:/remote/directory/
Copy directory from remote to local
scp -r username@from_host:/remote/directory/ /local/directory/
Remote to remote
Copy file from remote host to remote host
scp username@from_host:/remote/directory/file.txt username@to_host:/remote/directory/
find
sudo find / -type f -name '*.pem'
sudo find / -type d -name '*ssl*'
environment variables
env
printenv
Datas streams
STDIN | 0 |
STDOUT | 1 |
STDERR | 2 |
find /etc -type f 1>fin_results.txt 2>find_errors.txt