Beginner's Guide to Learning Linux Commands
1. Introduction
Linux is an open-source operating system that offers a powerful command line interface (CLI). This guide will detail basic commands and concepts for beginners who want to learn how to use the Linux command line.
2. Basic Commands
2.1. ls - List Files and Directories
- Usage:
ls [options] [directory] - Examples:
ls: Lists files and directories in the current directory.ls -l: Lists in long format.ls -a: Lists hidden files as well.
2.2. cd - Change Directory
- Usage:
cd [directory] - Examples:
cd /home: Changes to the /home directory.cd ..: Moves up one directory.cd: Moves to the home directory.
2.3. pwd - Show Current Directory
- Usage:
pwd - Example:
pwdshows the full path of the current working directory.
2.4. mkdir - Create a New Directory
- Usage:
mkdir [directory_name] - Example:
mkdir new_foldercreates a new directory namednew_folder.
2.5. rmdir - Remove an Empty Directory
- Usage:
rmdir [directory_name] - Example:
rmdir old_folderremoves an empty directory namedold_folder.
2.6. rm - Remove Files or Directories
- Usage:
rm [options] [file/directory] - Examples:
rm file.txt: Removesfile.txt.rm -r directory: Removes the directory and its contents.
3. File Operations
3.1. cp - Copy Files or Directories
- Usage:
cp [options] source destination - Examples:
cp file1.txt file2.txt: Copiesfile1.txttofile2.txt.cp -r dir1 dir2: Copies the contents ofdir1todir2.
3.2. mv - Move/Rename Files or Directories
- Usage:
mv [options] source destination - Examples:
mv file1.txt file2.txt: Renamesfile1.txttofile2.txt.mv file1.txt /target_dir: Movesfile1.txtto thetarget_dirdirectory.
3.3. cat - Display File Content
- Usage:
cat [file_name] - Example:
cat file.txtdisplays the content offile.txtin the terminal.
3.4. nano or vim - Edit Files
- Usage:
nano [file_name]: Edit a file with the nano editor.vim [file_name]: Edit a file with the vim editor.
- Example:
nano file.txtopensfile.txtin the nano editor.
4. File Permissions
4.1. chmod - Change File/Directory Permissions
- Usage:
chmod [options] permissions file - Examples:
chmod 755 file: Sets the permissions of the file to 755.chmod +x file: Adds execute permission to the file.
4.2. chown - Change File/Directory Ownership
- Usage:
chown [owner][:group] file - Example:
chown user:group filechanges the ownership of the file to the specified user and group.
5. System Control and Management
5.1. ps - Display Running Processes
- Usage:
ps [options] - Example:
ps auxlists detailed information about all running processes.
5.2. top - Monitor System Performance
- Usage:
top - Description: Displays real-time system performance, CPU, and memory usage.
5.3. df - Display Disk Usage
- Usage:
df [options] - Example:
df -hshows disk usage in a human-readable format.
5.4. du - Display Directory and File Sizes
- Usage:
du [options] [directory/file] - Example:
du -h directorylists sizes of files and subdirectories in the directory in a human-readable format.
6. Network Commands
6.1. ping - Test Network Connection
- Usage:
ping [target] - Example:
ping google.comtests the connection to google.com.
6.2. ifconfig - Display Network Interface Information
- Usage:
ifconfig - Description: Shows the status and configuration of network interfaces.
6.3. wget - Download Files
- Usage:
wget [URL] - Example:
wget http://example.com/file.zipdownloadsfile.zipfrom the specified URL.
7. Help and Documentation
7.1. man - View Command Manual Pages
- Usage:
man [command_name] - Example:
man lsopens the manual page for thelscommand.
7.2. --help - Command Help Option
- Usage:
[command_name] --help - Example:
ls --helpdisplays usage options for thelscommand.
8. Conclusion
This guide covers the basic commands and concepts for those who want to get started with the Linux command line. For more advanced commands and applications, refer to Linux documentation and online resources. The most important part of learning Linux is to practice what you have learned.
Release date : 08.07.2024 Author : Samet Views : 1086 Category : Linux