Basic Commands
echo: Prints text to the terminal.
- Example:
echo "Hello, World!" prints Hello, World!
clear: Clears the terminal screen.
CTRL + L: A keyboard shortcut to clear the terminal screen, similar to the clear command.
date: Displays the current date and time.
- Example:
date will output the current date and time like Fri Sep 8 10:34:12 UTC 2024.
history: Shows the list of previously entered commands in the terminal.
- Example:
history will list recent commands you've used.
File and Directory Manipulation
pwd: Prints the current working directory.
- Example:
pwd might output /home/user.
ls: Lists files and directories in the current directory.
- Example:
ls lists all files, ls -l shows detailed info (permissions, owner, etc.).
file: Determines the file type.
- Example:
file myfile.txt might return ASCII text if it's a text file.
cd: Changes the current directory.
- Example:
cd /home/user/Documents changes to the Documents directory.
mkdir: Creates a new directory.
- Example:
mkdir new_folder creates a directory called new_folder.
rmdir: Removes an empty directory.
- Example:
rmdir old_folder deletes the directory old_folder.
touch: Creates an empty file or updates the timestamp of an existing file.
- Example:
touch newfile.txt creates a file called newfile.txt.
>: Redirects output to a file (overwriting it if it exists).
- Example:
echo "Hello" > file.txt writes Hello into file.txt.
>>: Appends output to the end of a file.
- Example:
echo "World" >> file.txt appends World to file.txt.
tee: Redirects output to both a file and the terminal.
- Example:
echo "Hello" | tee output.txt writes Hello to output.txt and prints it on the terminal.
nano or vim: Text editors used in the terminal.
- Example:
nano file.txt opens file.txt in the nano editor.
cat: Displays the contents of a file.
- Example:
cat file.txt shows the content of file.txt.
less: Views the content of a file one page at a time.
- Example:
less file.txt allows you to scroll through file.txt.