Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views13 pages

Linux BasicLevel Moskalenko

Uploaded by

Roman Moskalenko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views13 pages

Linux BasicLevel Moskalenko

Uploaded by

Roman Moskalenko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Basic Level

3.1 User and group management.


1. Find all system users and display them in alphabetical order.
awk -F ':' '{print $1}' /etc/passwd | sort
2. List all system users sorted by ID.
awk -F ':' '{if ($3 < 1000) print $1 " " $3}' /etc/passwd | sort -k2n | awk
'{ print $1}'
3. Display users who cannot log in to the system.
https://serverfault.com/questions/576071/how-do-you-tell-if-a-user-is-
allowed-to-log-in-on-linux
awk -F: '/nologin|false/ {print $1}' /etc/passwd
4. Create a new user <second_name>_<learn_id> (substitute it by your own
student attributes), ensure the linux_lab group exists, add the user to this
group and set a password.

vagrant@UbuntuLinuxVM:~$ sudo groupadd -f linux_lab


vagrant@UbuntuLinuxVM:~$ sudo useradd -m -G linux_lab
moskalenko_320878_1
vagrant@UbuntuLinuxVM:~$ sudo passwd moskalenko_320878_1
New password:
Retype new password:
passwd: password updated successfully
vagrant@UbuntuLinuxVM:~$
3.2 File and directory operations
5. Find all files in /etc modified in the last 24 hours.
vagrant@UbuntuLinuxVM:~$ sudo find /etc -type f -mtime -1
/etc/machine-id
/etc/multipath/bindings
/etc/shadow
/etc/subgid-
/etc/netplan/50-vagrant.yaml
/etc/netplan/50-cloud-init.yaml
/etc/hosts
/etc/subuid
/etc/passwd-
/etc/mailname
/etc/apt/sources.list
/etc/fstab
/etc/subuid-
/etc/group
/etc/gshadow-
/etc/passwd
/etc/group-
/etc/hostname
/etc/gshadow
/etc/sudoers.d/90-cloud-init-users
/etc/shadow-
/etc/subgid
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_host_ed25519_key.pub
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_ecdsa_key
6. List files larger than 100MB in /var/log. If no such files exist, modify the
size threshold to find files large than 3MB.
vagrant@UbuntuLinuxVM:~$ sudo find /var/log -type f -size +100
/var/log/syslog
/var/log/journal/931e6cc5ac0f45dc82c88a0eab9e70f2/user-
[email protected]~
/var/log/journal/931e6cc5ac0f45dc82c88a0eab9e70f2/user-1000.journal
/var/log/journal/931e6cc5ac0f45dc82c88a0eab9e70f2/
[email protected]~
/var/log/journal/931e6cc5ac0f45dc82c88a0eab9e70f2/system.journal
/var/log/cloud-init.log
/var/log/kern.log
/var/log/lastlog
7. Find files in /home that have execution permissions for the group. Then,
change their permissions to the least privilege setting and document what
each permission type means, including the sticky bit.
sudo find /home -type f -perm -g=x -print -exec chmod 400 {} \;
Chmod value 1600 means:
 1 sticky bit is set, it means Prevents deletion of files by users who don't
own them.
 4 only read permission is set to user
 0 no permissions for group
 0 no permissions for others

3.3 Working with links

8. Find all symbolic links in /home and display their targets. Additionally,
find and list all hard links to a specific file (e.g. /bin/bash or create a file and
hard links by yorself).

sudo find /home -type l -exec ls -l {} \;


9. Create both a symbolic and a hard link for a test file in your home
directory. Modify the original file and observe the behavior of both links.
Remove the original test file and check the links again.
 The symbolic link and hard link is created for file script_1
 both symbolic and hard links values changed after appending to original
file

 After deletion, hard link values haven’t changed, but symbolic link says
that is no such file or directory.

10. Identify and handle broken symbolic links and assess files with multiple
hard links in the home directory.
sudo find /home -xtype l -exec ls -l {} \;
sudo find /home -type f -links 3

You might also like