Basic Input/Output and Process Control
- Reading from a File:
cmd < ios.md
: Reads input
cmd << ok
: Reads until "ok" is entered on a new line.
- Writing to a File:
cmd > file.txt
: Overwrites .
cmd >> file.txt
: Appends
cmd > null
: Discards all
- Piping Output:
cmd1 | cmd2
: Directs output of cmd1
as input to cmd2
.
- Showing Success/Failure:
- Variables:
var='hello'
: Creates a variable
echo $var
: Displays
- Running in Background:
cmd &
: Runs cmd
in the background.
Wildcards for File Matching
hello*.jsx
: Matches files starting with "hello" and ending with ".jsx"
test?.jsx
: "test", followed by any single character
{c,m,p}at
: Matches "cat", "mat", or "pat".
{1..9}
: 1 to 9
System Information
whoami
: Shows your current username.
who
: Lists all users currently logged in.
man cmd
: Displays manual page (notes style) for cmd
.
su <user>
: Switches to the specified user, requiring their password. If no user is specified, it defaults to the root user.
passwd <user>
: Changes the password for the specified user.