As I am very new to UNIX and struggling with two commands to get the desired output.
- What will be the command to print the name of the largest file in size in /usr/include directory.
I tried but not giving the filename whose size is largest :
find /usr/include -type f -exec ls -s {} \; | sort -n | tail -n 5
- command to print user ids on a Linux environment which can’t be used as login ids. [hint: consider /etc/passwd file]
I tried: cat /etc/passwd
Please let me know if these are the correct commands.
CodePudding user response:
ls -lS /usr/include | head -2 | grep -v total
Flag S is to sort files by size. Head then grabs the first 2 lines of the long output and grep removes the summary line.
awk -F: '{ if($3<100) print $1;}' /etc/passwd
UID is the third field in /etc/passwd. Generally UIDs 0-99 are reserved for predefined system accounts. So this command prints all usernames with UID less than 100.