Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What command would I use to find all regular files under my home (~) director

ID: 3834068 • Letter: 1

Question

1. What command would I use to find all regular files under my home (~) directory whose file size is less than 4096 bytes, whose extension is .txt? 2. I want to create a new user shagar. I want his home directory to be /home/sammy, and I want his user ID to be 55. What single command would do this? 3. I have a file called "backup2.tar.gz" which is owned by user thowell. I want to change the owner of that file to user 'gingergrant'. What command would do this? 4. I have a file called 'backup.tgz' in my home directory. I want to uncompress and unarchive the files in it. What command would I use? 5. What single command would I run to make the following directory structure: ~/Videos/three/two/one?

Explanation / Answer

a) What command would I use to find all regular files under my home (~) directory whose file size is less than 4096 bytes, whose extension is .txt?
Ans) find ~ -type f -name '*.txt' -size -4k 2>/dev/null
4096 bytes is 4K. Thats why to determine files of size less than 4K we have used the option "-size -4k" and "2>/dev/null" is used in the command to send files with permission error /dev/null

b) I want to create a new user shagar. I want his home directory to be /home/sammy, and I want his user ID to be 55. What single command would do this?
Ans) useradd -u 55 -d /home/sammy shagar
We can create new user with userid and new home directory with just one useradd command. '-u' is the option for giving userid and '-d' for home directory.

c) I have a file called "backup2.tar.gz" which is owned by user thowell. I want to change the owner of that file to user 'gingergrant'. What command would do this?
Ans) chown gingergrant backup2.tar.gz
chown changes owner of the file to the specified owner name

d) I have a file called 'backup.tgz' in my home directory. I want to uncompress and unarchive the files in it. What command would I use?
Ans) tar -xvzf backup.tgz
We can use tar command to extract the gizzed file and upcompress the files in it.

e) What single command would I run to make the following directory structure: ~/Videos/three/two/one?
Ans) mkdir -p ~/Videos/three/two/one
'-p' option in mkdir allows us to create intermediate directories if it does not exist. That way we can directory structure with a single command.