If you can see this check that

           prev section up prev page next page

Tutorial 5


Pipes

User:
Password:

A quick introduction to pipe.

To reset all the check buttons from a previous attempt click here

Question 1: Update demo account

The button below will create the demo account and create the files club_members and names for use with this tutorial.

By pressing the button below an account is created called "demo", password is also "demo". Log in using this account and you cannot do any damage. If you mess the account up and want to start again, delete the files club_members and names and then press the button again.

Once created, you can log into this account using telnet or ssh, logging into the hostname linuxzoo.net. Remember the username is demo and the password is demo. And remember, you cannot break anything using this account! The account begins with an empty directory, so dont be shocked that "ls" shows nothing...

Tests - not attempted
Update an account called demo, password demo UNTESTED

Question 2: sort

Using cat create a pipe that will concatenate the two files club_members and names, sort them and send the output to the file s1.

Tests - not attempted
cat and sort UNTESTED

Question 3: reverse sort

Using cat create a pipe that will concatenate the two files club_members and names, sort them in reverse order and send the output to the file s2.

Tests - not attempted
reverse sort UNTESTED

Question 4: sort on a field

Sort the file club_members numerically by meetings attended (this is the last field). Send the output to file s3

Tests - not attempted
sort on field UNTESTED

Question 5: sort with field separator

Sort the /etc/passwd numerically by user id numbers (third field) in ascending order. You may wish to use the -t option here. Send the output to file s4

Tests - not attempted
reverse sort UNTESTED

Question 6: using grep

Use grep on /usr/share/dict/words to find the first word that contains the three letter sequence wta
wta word:

Tests - not attempted
Dictionary search UNTESTED

Question 7: count with grep

Use grep piped through wc on file /usr/share/dict/words to find the number of words that contain the letter x.
ber words:

Tests - not attempted
x word count UNTESTED

Question 8: negative grep

Use grep to find all lines in /etc/passwd that do not have nologin one the line. Make grep include the line numbers of the matching lines and send the output to file s5

Tests - not attempted
not nologin UNTESTED

Question 9: grep and ls

Use ls -l and grep to find all the files in the directory /etc that were last modified in March (hint: try looking for the case sensitive string "Mar"). Send this list to s6.

Tests - not attempted
ls and grep UNTESTED

Question 10: ls grep and sort

Use ls -l and grep and sort to find all the files in /etc that were last modified in Jun. Sort this list in descending order of size and then alphabetically by name (so 2 files with the same size will appear in alphabetic order). Send the output to s7. Sorting using other techniques will probably not get the same answer...

Tests - not attempted
Jun files in order UNTESTED

Question 11: find root files

Find all the files and directories in /var (including subdirectories) that are owned by user root. Send the list of full path names to s8.

Your find command may produce "Permission Denied" errors during this search. This will have no effect on the answer, and this error can be safely ignored for this question.

Tests - not attempted
find apache UNTESTED

Question 12: find .conf files

Find all the files in /etc (including subdirectories) end .conf Send the list of full path names to s9.

Your find command may produce "Permission Denied" errors during this search. This will have no effect on the answer, and this error can be safely ignored for this question.

Tests - not attempted
find .conf UNTESTED

Question 13: find new files

Find all the files and directories in the demo directory that are newer than s1. Send the output of the command to /var/tmp/t1 (don't send it to the demo directory). The names of the files should appear as full names. For example, the file "s5" would appear as "/home/demo/s5". The "/home/demo", if it appears in the output, should not have a trailing "/". The secret to avoiding the trailing slash is to use "/home/demo" not "/home/demo/" in the find command.

Tests - not attempted
find new files UNTESTED

Question 14: list large files

Find all the files in the directory directory /etc/ and its subdirectories that are larger than 1 megabyte (which you can assume is 2048 blocks of 512 bytes). Send the output to s10.

Your find command may produce "Permission Denied" errors during this search. This will have no effect on the answer, and this error can be safely ignored for this question.

Tests - not attempted
find big files UNTESTED

Question 15: small xsl files

Create a directory called smallc in /home/demo. Copy into it all the file that begin with s from /usr/include that are smaller or equal to 12K. You may find these instructions on the use of find from Developer's Daily useful.

Your find command may produce "Permission Denied" errors during this search. This will have no effect on the answer, and this error can be safely ignored for this question.

Tests - not attempted
copy small xsl UNTESTED


Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
Caine 13.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Registry | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2024 Edinburgh Napier University