July 22, 2024
Linux is a leading operating system in the IT industry due to its open-source nature, meaning it is free, and its vast community that provides support at every stage. Currently, a significant percentage of businesses use Linux, making it essential to learn, regardless of preference. Believe us, it is very easy; you only need to start.
To become proficient in any operating system, the first priority should be basic navigation and file management. Let's start with this:
ls - Lists directory contents.
ls -l - Provides a detailed list including permissions, number of links, owner, group, size, and timestamp.
ls -a - Lists all files, including hidden files.
cd /path/to/directory - Changes to the specified directory.
cd .. - Moves up one directory level.
cd ~ - Changes to the user's home directory.
pwd - Displays the full path of the current directory.
mkdir - Creates a new directory.
rm file - Removes a file.
rm -r directory - Recursively removes a directory and its contents. Remember: Use -r for directories because it requires a recursive call.
cp source destination - Copies a file.
cp -r source_directory destination_directory - Recursively copies a directory.
mv old_file.txt new_file.txt - Renames a file or directory.
mv file.txt /new/directory/ - Moves a file to a new directory.
nano file.txt - Opens a file in the Nano editor.
vi file.txt - Opens a file in the Vi or Vim editor. Note: Vi is the default editor, but Vim needs to be installed.
grep 'search_term' file.txt
grep -r 'search_term' /directory/
find /home -name "file.txt" - Finds files by name.
find /home -type d - Finds directories.
sudo command allows a permitted user to execute a command as the superuser or another user, e.g., sudo apt-get update.
df -h - Shows disk space in a human-readable format.
du -h - Displays sizes in a human-readable format.
du -sh directory - Summarizes the total space used by a directory.
These commands function like a task manager.
wget http://example.com/file
scp file user@remote:/path
ssh user@hostname
echo "Hello, World!" > file.txt - Writes/overwrites "Hello, World!" to a file.
echo "Hello, World!" >> file.txt - Appends "Hello, World!" to the existing content. Overwrite content with >; append content with >>.
cat file.txt
head file.txt - Displays the first 10 lines.
tail file.txt - Displays the last 10 lines.