Question

write the commands to print out ones entry in /etc/passwd file in unix operating system.

write the commands to print out ones entry in /etc/passwd file in unix operating system.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

cut -d: -f1,3,4 /etc/passwd | tr ':' '\t'

Explanation:

An example of entries in the /etc/passwd file:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh

cut can deal with character separated lines in text files

The options for cut to work are:

  1. -d: Using a colon as delimiter
  2. -f1,3,4 - outputs fields 1,3,and 4. Cut uses 1-indexing

Now the output of cut -d: -f1,3,4 /etc/passwd would have colon-delimited fields

To eliminate that we can use the translate command : tr

So the output is passed through a pipe and operated upon the tr command which replaces the colon with tabs ('\t')

Add a comment
Know the answer?
Add Answer to:
write the commands to print out ones entry in /etc/passwd file in unix operating system.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Operating System Lab (CE 351) Lab 6: Users and groups Help: study the file /etc/passwd (page...

    Operating System Lab (CE 351) Lab 6: Users and groups Help: study the file /etc/passwd (page 19 from the notes) Helping commands: useradd passwd userdel groupadd cut grep su Lab exercises: 1. Implement the following tasks: a. Copy the contents of /etc/passwd file separated by space into new.txt file b.Delete a user whose ID is > 1000 ( hint: use shell scripting and the file /etc/passwd)

  • Objective: Practice common UNIX commands. Procedure: The following list of Unix commands are given for self-learning....

    Objective: Practice common UNIX commands. Procedure: The following list of Unix commands are given for self-learning. Use 'whatis' or 'man' command to find out about each command. Your document should include the description or screen shots of the output from each of the command. Commands: df du gzip file history wget Changing access rights: chmod u+x Dir1.0            adds execute permission for the owner chmod go-w file1              removes write permission for the group and others chmod ugo=rw testfile     sets...

  • Write a command to order the file /etc/passwd on GID (primary) and UID (secondary) so that...

    Write a command to order the file /etc/passwd on GID (primary) and UID (secondary) so that users with the same GID are placed together. Users with a lower UID shall be placed higher in the list.

  • Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a...

    Exercise 1: Write a shell script that loops through the /etc/passwd file one line at a time. Prepend each line with a line number followed by a colon and then a space. Example output: 1: root:x:0:0:root:/root:/bin/bash 2: daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 3: bin:x:2:2:bin:/bin:/usr/sbin/nologin 4: sys:x:3:3:sys:/dev:/usr/sbin/nologin Exercise 2: Write a shell script that asks the user for the number of lines they would like to display from the /etc/passwd file and display those lines. Example output: How many lines of /etc/passwd would you like...

  • Objective: The objective of this lab is to work with files of UNIX file system. Procedure:...

    Objective: The objective of this lab is to work with files of UNIX file system. Procedure: 1. OpenyourUnixshellandtrythesecommands: Ø Create a new file and add some text in it v cat > filename Ø View a file v cat /etc/passwd v more /etc/passwd v more filename Ø Copy file1 ,making file2 v cp file1 file2 Ø Rename file1 as file2 v mv file1 file2 Ø Delete file1 as file2 vrm file //Deletefile // Double-check first v rm -i file Ø...

  • e) In the context of Unix file system , what does "path" means? f) Write down...

    e) In the context of Unix file system , what does "path" means? f) Write down the absolute path for the main.cpp in the timeproj directory g)Write down the relative path from inside timeproj directory to the prgm1.cpp file h)Write down the Unix commands and key strokes needed to create a new sourcefile named time.cpp and then save it to disk using the pico editor. i) In Unix each file has three access modes, namely r,w, and x. 1) Write...

  • File structure is a structure, which is according to a required format that operating system can...

    File structure is a structure, which is according to a required format that operating system can understand. A file has a certain defined structure according to its type. A text file is a sequence of characters organized into lines. A source file is a sequence of procedures and functions. An object file is a sequence of bytes organized into blocks that are understandable by the machine. When operating system defines different file structures, it also contains the code to support...

  • Operating System: In a combined UNIX UFS file system, with single, double and triple indirect poi...

    Operating System: In a combined UNIX UFS file system, with single, double and triple indirect pointers, answer the following: a) what is the maximum possible size of a file? Assume that a pointer takes 4 bytes and that blocks are 128 bytes long. b) In a file of maximum size, what is the ratio of storage in bytes consumed by all the pointers and pointer blocks to the maximum file size in bytes? Operating System: In a combined UNIX UFS...

  • What are the key features of file management in the UNIX operating system? Discuss the challenges...

    What are the key features of file management in the UNIX operating system? Discuss the challenges you have faced in attempting to install and configure UNIX. Explain how the designers of the Windows operating system had to incorporate a set of five software design goals; extensibility, portability, reliability, compatibility, and performance. Discuss the role of the I/O Manager. Discuss how Kerberos security provides effective distributed security. What is the difference between device management in the Windows operating systems and MS-DOS?...

  • Q1) A particular implementation of UNIX operating system provides the file structure modelled in the Figure...

    Q1) A particular implementation of UNIX operating system provides the file structure modelled in the Figure 1. Here the i-node for the file contains certain information such as the access permissions for the file. This is followed by the entries that contain information about where the file is located on the storage device. The first 10 entries are the addresses of blocks where actual data for the file are stored. If block can contain 512 bytes of information, then these...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT