Understanding Command Syntax
July 1, 2023Understanding the File System Hierarchy and Mounting Devices in Ubuntu
July 1, 2023I/O Redirection, Using Pipes, Bash Completion, Editing Files with vim and Nano
1. I/O Redirection
- Create a file named
file1.txt
and write “Hello, World!” into it using I/O redirection. - Create a file named
file2.txt
and append “How are you?” into it using I/O redirection. - Display the contents of
file1.txt
andfile2.txt
using I/O redirection.
2. Using Pipes
- List all the files in your current directory and use a pipe to pass the output to
grep
to find all.txt
files. - Use the
ps
command to show your current processes, and use a pipe to pass the output togrep
to find a specific process.
3. History
- Execute the last command again using the
history
command. - Execute the 5th command from your history.
4. Bash Completion
- Start typing the name of a file or directory, then use bash completion to finish typing it.
- Start typing a command, then use bash completion to finish typing it.
5. Editing Files with vim
- Create a new file named
file3.txt
and open it with vim. - Switch to insert mode and write “This is a test.” Save and quit.
- Reopen
file3.txt
, delete “a test”, and replace it with “an exercise”. Save and quit.
6. Editing Files with nano
- Create a new file named
file4.txt
and open it with nano. - Write “This is another test.” Save and exit.
- Reopen
file4.txt
, delete “another test”, and replace it with “another exercise”. Save and exit.
Remember, the best way to learn is by doing. Don’t be afraid to experiment and try different things.