-
List files and directories:
ls
Options:
ls -l
: List with details (permissions, size, etc.).ls -a
: Show hidden files.ls -lh
: List with human-readable file sizes.
-
Change directory:
cd [directory]
Examples:
cd /home/user
: Go to a specific directory.cd ..
: Move up one directory.cd ~
: Go to the home directory.
-
Create a directory:
mkdir [directory_name]
-
Remove a file or directory:
rm [file_name] rm -r [directory_name]
rm -r
: Removes directories and their contents recursively.- Caution: Use with care; this action is permanent.
-
Copy files or directories:
cp [source] [destination]
- Add
-r
for directories:cp -r source_dir dest_dir
.
- Add
-
Move or rename files:
mv [source] [destination]
-
open in VS Code current directory:
code .
-
open in VS codium current directory:
codium .
-
View file content:
cat [file_name]
cat file.txt
: Display the entire content.
-
Search within a file:
grep [search_term] [file_name]
- Example:
grep "error" logs.txt
- Example:
-
Display first/last lines of a file:
head [file_name] tail [file_name]
-
Edit a file:
Use editors likenano
,vim
, orgedit
:nano [file_name]
-
Display current directory:
pwd
-
Check disk usage:
df -h du -sh [file_or_directory]
-
Change file permissions:
chmod [permissions] [file_name]
Example:
chmod 755 script.sh
-
Change file ownership:
chown [owner]:[group] [file_name]
-
Install a package (Ubuntu/Debian):
sudo apt install [package_name]
-
Update package lists:
sudo apt update
-
Upgrade installed packages:
sudo apt upgrade
This list covers fundamental commands for beginners. Explore their manual pages (man [command]
) for more options.