Home > Back-end >  Ubuntu commands UNIX - to find the user ids which can't used as login id and to print the large
Ubuntu commands UNIX - to find the user ids which can't used as login id and to print the large

Time:03-24

As I am very new to UNIX and struggling with two commands to get the desired output.

  1. 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

  1. 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:

  1. 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.

  1. 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.

  • Related