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

Perform simple Linux commands Create some empty files at the \"two\" directory c

ID: 3879508 • Letter: P

Question

Perform simple Linux commands

Create some empty files at the "two" directory called "test1", "test2", and "test3". Use "ls" to show that they are there

Show the long file listing of just test1 and test2 using wildcards

From the home directory, show the long listing of one/passwd file

From the home directory, delete the one/passwd file. Use "ls" to show that it's gone

Show the manual page for the "mkdir" command

Show the manual page for the "mkdir" API function

Create an alias called "home" that does two things... returns you to your home directory, then does a long listing of all files found there

Create a file called "Output.txt" that contains the output of the "ls /etc." command

Using "cat", create a file called "poem.txt" where you enter at least one line of text ("Mary had a little lamb" will do...)

Explanation / Answer

1)Creating a directory "two".

mkdir two

*Creating empty files test 1,2,3.

touch test1 test2 test3

*list to shw the files in that directory named "two".

ls

2)Long file listing for test1 and test2 using wildcards

Using star wildcard:

test1 *

test2 *

Using Questionmark wildcard:

test1 ???

-(the following would return data on all objects in the current directory whose names, inclusive of any extensions, are exactly three characters in length)

test2 ? ?? ???

-(And the following would provide data on all objects whose names are one, two or three characters in length)

Using Square bracket wildcard:

test1 *[xyz]*

-(the following would provide information about all objects in the current directory that have an x, y and/or z in them)

And the following would list all files that had an extension that begins with x, y or z:

ls *.[xyz]*

3)Many systems have a getent command to list or query the content of the Name Servicedatabases like passwd, group, services, protocols...

getent passwd | cut -d: -f6

Would list the home directories (the 6th colon delimited field) of all the users in databases that can be enumerated.

The user name itself is in the first field, so for the list of user names:

getent passwd | cut -d: -f1

(note that it doesn't mean those users can login to the system or their home directory have been created, but that they are known to the system, they can be translated to a user id).

4)From the home directory, delete the one/passwd file.

rm one/passwd

ls

5)Show the manual page for the "mkdir" command

man mkdir

6)Show the manual page for the "mkdir" API function

man mkdir(3)

-Prolog

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

7)Create an alias called "home" that does two things... returns you to your home directory, then does a long listing of all files found there

alias home="$ cd " ; "ls *"

8)Create a file called "Output.txt" that contains the output of the "ls /etc." command

touch output.txt

ls/etc>>output.txt

9)Using "cat", create a file called "poem.txt" where you enter at least one line of text ("Mary had a little lamb" will do...)

You can create a new file with the name poem.txt using the following cat command and you can type the text you want to insert in the file. Make sure you type ‘Ctrl-d’ at the end to save the file.

$ cat > poem.txt

Mary had a little lamb.

Now you can display the contents of the file poem.txt by using the following command.

$ cat poem.txt

Mary had a little lamb.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote