Skip to main content

Command Palette

Search for a command to run...

homework linux 3

๐Ÿ” grep Tasks

  1. Search for the word Linux in file.txt.

  2. Search case-insensitively for ubuntu.

  3. Count how many lines contain error.

  4. Show only the matching part using -o.

  5. Show line numbers with matches.

  6. Search recursively in a folder.

  7. Invert match to find lines without hello.

  8. Use regex to match lines starting with "A".

  9. Match exact whole word root.

  10. Combine with ps aux | grep ssh.


๐Ÿ—‘๏ธ rm Tasks

  1. Delete a file temp.txt.

  2. Delete multiple files rm a.txt b.txt.

  3. Delete all .log files in a directory.

  4. Use rm -i to confirm before deletion.

  5. Delete a folder and its contents recursively.

  6. Delete hidden files in current directory.

  7. Delete files older than 2 days using find and rm.

  8. Prevent rm from deleting a file with chattr +i.

  9. Try rm -v to see whatโ€™s being removed.

  10. Use rm -r on a test directory testdir/.


โžก๏ธ Redirection > Tasks

  1. Write output of date to today.txt.

  2. Redirect whoami to a file.

  3. Overwrite test.txt with echo.

  4. Redirect ls -l to a new file.

  5. Redirect error from cat nofile to err.txt.

  6. Redirect command output into /dev/null.

  7. Save disk usage to disk.txt.

  8. Run uptime and save output.

  9. Redirect list of users from /etc/passwd.

  10. Check if file was overwritten.


โž• Append >> Tasks

  1. Append current time to log.txt.

  2. Append uname -a to sysinfo.txt.

  3. Add a new line to an existing file.

  4. Save the result of multiple commands into one file.

  5. Combine with echo to create a multiline file.

  6. Append ping results to pinglog.txt.

  7. Append errors of a failed command.

  8. Add student names to a list file.

  9. Append system uptime daily (cron job idea).

  10. Log current directory to path.log.


๐Ÿ“ฅ๐Ÿ“ค stdin, stdout, stderr Tasks

  1. Use cat without file to enter text from stdin.

  2. Redirect stdout of ls to out.txt.

  3. Redirect stderr from cat wrong to error.txt.

  4. Use 2>&1 to combine error and output.

  5. Pipe stdin from echo to another command.

  6. Write a command that reads from a file as stdin.

  7. Filter only errors using 2> redirection.

  8. Send output to screen and file using tee.

  9. Use | to pass stdout as stdin to grep.

  10. Demonstrate stdin with read in a script.


๐Ÿ”ก sort Tasks

  1. Sort a list of names in a file.

  2. Sort numbers in ascending order.

  3. Sort with -r for reverse.

  4. Sort and remove duplicates.

  5. Sort by numeric value -n.

  6. Sort by a specific column in a CSV file.

  7. Sort ignoring case.

  8. Sort file and save result.

  9. Combine with uniq to show unique sorted lines.

  10. Sort the result of ps aux.


๐Ÿ” uniq Tasks

  1. Remove duplicate lines from names.txt.

  2. Count unique lines using -c.

  3. Show only repeated lines using -d.

  4. Show only unique lines using -u.

  5. Sort a file then apply uniq.

  6. Chain with sort | uniq -c.

  7. Show how many times each IP appears in access.log.

  8. Detect duplicates in student list.

  9. Use uniq on sorted numeric values.

  10. Count unique error messages in a log file.


๐Ÿ”Ž find Tasks

  1. Find all .txt files.

  2. Find files modified in last 1 day.

  3. Find files bigger than 5MB.

  4. Find empty files.

  5. Find files with -name and delete them.

  6. Find all hidden files.

  7. Find files with 777 permissions.

  8. Find files owned by a user.

  9. Find and archive results.

  10. Find directories only.


โœ‚๏ธ cut Tasks

  1. Extract first column of a CSV.

  2. Cut usernames from /etc/passwd.

  3. Extract the second field by delimiter : from a file.

  4. Cut first 10 characters from each line.

  5. Extract filename from full path.

  6. Combine with ls -l | cut to get file sizes.

  7. Show domains from email list.

  8. Cut and save result to cut.txt.

  9. Extract year from date YYYY-MM-DD.

  10. Use cut with df -h to display only used percent.


๐Ÿง  awk Tasks

  1. Print the first column from /etc/passwd.

  2. Print 1st and 3rd column from a CSV.

  3. Sum all numbers in second column.

  4. Print lines where second field > 100.

  5. Count lines with more than 3 fields.

  6. Replace "admin" with "user" in a file.

  7. Format output: awk '{print "Name: "$1}'.

  8. Calculate average from a column.

  9. Use condition if in awk.

  10. Chain grep | awk to format filtered output.