Linux Command Line Basics
The Linux Command Line Interface (CLI), also known as the shell or terminal, is a powerful tool for interacting with the operating system. Mastering basic commands is essential for developers, especially when working with servers, cloud environments, or containers.
1. Navigation
pwd(Print Working Directory): Shows the full path of the current directory.ls(List): Lists files and directories in the current folder.ls -l: Detailed list (permissions, size, owner).ls -a: Show hidden files (starting with.).
cd(Change Directory): Moves to a different folder.cd documents: Go to 'documents'.cd ..: Go up one level.cd ~: Go to the home directory.
2. File Manipulation
touch filename: Creates an empty file or updates the timestamp of an existing one.mkdir foldername: Creates a new directory.cp source destination: Copies files or directories.cp -r folder new_folder: Recursively copy a directory.
mv source destination: Moves or renames files.rm filename: Removes (deletes) a file. Warning: There is no Recycle Bin.rm -r folder: Removes a directory and its contents.
3. Viewing File Content
cat filename: Prints the entire content of a file to the screen.less filename: View file content one page at a time (use arrows to scroll,qto quit).head filename: Shows the first 10 lines of a file.tail filename: Shows the last 10 lines of a file.tail -f filename: Follows the file in real-time (great for logs).
4. Permissions
Linux file permissions determine who can read, write, or execute a file.
chmod(Change Mode): Changes permissions.chmod +x script.sh: Make a file executable.chmod 755 file: Owner can read/write/execute; others can read/execute.
chown(Change Owner): Changes the file owner and group.chown user:group file
5. System & Processes
sudo(SuperUser DO): Runs a command with administrative (root) privileges.top/htop: Displays running processes and resource usage (CPU, RAM).ps: Lists current processes.kill pid: Terminates a process by its Process ID (PID).grep: Searches for text patterns within files or output.cat file.txt | grep "error": Find lines containing "error".
programming/docker-and-containers programming/cloud-computing-basics