Skip to content

Commit 830e591

Browse files
authored
Added Beginner Guide to Linux.
1 parent ca7aff7 commit 830e591

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

docs/Contribution Guidelines/CONTRIBUTING.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,115 @@ New to Git? Check out these resources:
227227
tutorial
228228
- [Oh Shit Git](https://ohshitgit.com/) - Common problems and solutions
229229

230+
## Essential Linux Usage for Contributors
231+
232+
Linux is a powerful open-source operating system. As a contributor, understanding basic command-line usage is key. This guide covers essential commands, system updates, and best practices for command-line work.
233+
234+
---
235+
236+
### Basic Linux Commands
237+
238+
The command line is your main interface. Here are core commands you'll use often:
239+
240+
* **`ls` (list):** Shows directory contents.
241+
* `ls`: Lists files and directories in the current location.
242+
* _Example:_ `ls` might output `documents images myproject.txt`
243+
* `ls -l`: Provides a "long listing" with details like permissions, size, and date.
244+
* _Example:_ `ls -l` might show `-rw-r--r-- 1 user group 1024 Jul 10 10:30 myproject.txt`
245+
* `ls -a`: Shows all files, including hidden ones (starting with a `.`).
246+
* _Example:_ `ls -a` might reveal `.bashrc .config documents`
247+
* **`cd` (change directory):** Navigates between directories.
248+
* `cd <directory_name>`: Moves to a specific directory.
249+
* _Example:_ `cd documents`
250+
* `cd ..`: Moves up one directory level.
251+
* _Example:_ If in `/home/user/documents`, `cd ..` moves to `/home/user/`
252+
* `cd ~`: Returns to your home directory.
253+
* _Example:_ No matter where you are, `cd ~` takes you to `/home/user/`
254+
* **`pwd` (print working directory):** Displays your current directory's full path.
255+
* _Example:_ `pwd` might output `/home/user/myproject`
256+
* **`mkdir` (make directory):** Creates a new directory.
257+
* _Example:_ `mkdir new_folder`
258+
* **`rmdir` (remove directory):** Deletes an empty directory.
259+
* _Example:_ `rmdir empty_folder`
260+
* **`touch`:** Creates an empty file or updates a file's timestamp.
261+
* _Example:_ `touch new_file.txt` (creates a new empty file)
262+
* **`cp` (copy):** Copies files or directories.
263+
* `cp <source_file> <destination_file>`: Copies a file.
264+
* _Example:_ `cp report.docx report_backup.docx`
265+
* `cp -r <source_directory> <destination_directory>`: Copies a directory and its contents.
266+
* _Example:_ `cp -r myproject myproject_copy`
267+
* **`mv` (move):** Moves or renames files/directories.
268+
* _Example (move):_ `mv old_file.txt documents/` (moves `old_file.txt` into the `documents` folder)
269+
* _Example (rename):_ `mv old_name.txt new_name.txt`
270+
* **`rm` (remove):** Deletes files or directories.
271+
* `rm <file_name>`: Deletes a file.
272+
* _Example:_ `rm unwanted_file.txt`
273+
* `rm -r <directory_name>`: Recursively deletes a directory (use with extreme caution!).
274+
* _Example:_ `rm -r old_project_folder` (Deletes the folder and everything inside it)
275+
* **`cat` (concatenate):** Displays a file's content.
276+
* _Example:_ `cat README.md` (shows the content of the README.md file)
277+
* **`less` / `more`:** Views file content page by page for large files.
278+
* _Example:_ `less /var/log/syslog` (allows you to scroll through a large log file; press `q` to quit)
279+
* **`grep`:** Searches for text patterns within files.
280+
* _Example:_ `grep "error" /var/log/syslog` (finds all lines containing "error" in the syslog file)
281+
* **`man` (manual):** Provides documentation for commands.
282+
* _Example:_ `man ls` (shows the manual page for the `ls` command; press `q` to quit)
283+
284+
---
285+
286+
### How to Update and Upgrade the System
287+
288+
Keeping your system updated is vital for security and new features. For Debian-based systems (like Ubuntu), use `apt`:
289+
290+
* **`sudo apt update`**: Refreshes the list of available packages from repositories.
291+
* _Example:_ `sudo apt update` (You'll see a list of package information being downloaded)
292+
* **`sudo apt upgrade`**: Installs newer versions of all currently installed packages.
293+
* _Example:_ `sudo apt upgrade` (Prompts you to confirm the installation of available updates)
294+
* **`sudo apt full-upgrade`**: Performs a more comprehensive upgrade, installing new packages if needed for dependencies and removing obsolete ones.
295+
* _Example:_ `sudo apt full-upgrade` (Use for major system version upgrades or when `upgrade` is insufficient)
296+
297+
**To update:**
298+
299+
1. Open your terminal.
300+
2. Run `sudo apt update`.
301+
3. Then, run `sudo apt upgrade`.
302+
4. Optionally, use `sudo apt full-upgrade` for a deeper update.
303+
304+
---
305+
306+
### How `sudo` and `apt` Work
307+
308+
* **`sudo` (SuperUser DO):**
309+
* **Function:** Allows you to run commands with **root (administrator) privileges** using *your own password*.
310+
* **When to use:** For tasks requiring elevated permissions, like installing software, modifying system files, or managing services.
311+
* **Caution:** Always be careful with `sudo`; incorrect commands can harm your system.
312+
* _Example:_ `sudo systemctl restart apache2` (restarts the Apache web server, requires root privileges)
313+
314+
* **`apt` (Advanced Package Tool):**
315+
* **Function:** A command-line utility for managing software packages (installing, updating, removing) on Debian-based systems. It interacts with software repositories.
316+
* **When to use:**
317+
* `apt install <package_name>`: Install new software.
318+
* _Example:_ `sudo apt install git` (installs the Git version control system)
319+
* `apt remove <package_name>`: Uninstall software (leaves configuration files).
320+
* _Example:_ `sudo apt remove firefox`
321+
* `apt purge <package_name>`: Uninstall software and its configuration files.
322+
* _Example:_ `sudo apt purge apache2`
323+
* `apt search <keyword>`: Find packages.
324+
* _Example:_ `apt search text editor` (lists available text editor packages)
325+
326+
---
327+
328+
### Tips for Command-Line Navigation and Safety
329+
330+
Here are some best practices to make your command-line work more efficient and secure:
331+
332+
* **Tab Completion:** Press the `Tab` key to auto-complete commands, file names, or directory names. Press `Tab` twice to see all available options if there's more than one.
333+
* **Arrow Keys:** Use the `Up` and `Down` arrow keys to cycle through your command history. This saves typing and helps recall previous commands.
334+
* **`Ctrl+R` (Reverse Search):** Press `Ctrl+R` and start typing to search your command history for a specific command. It's incredibly useful for finding a command you ran a while ago.
335+
* **Read the Manual (`man`):** If you're unsure about a command or its options, use `man <command_name>` for detailed documentation. Press `q` to quit the manual.
336+
* **Be Careful with `sudo`:** Always double-check your commands before pressing Enter when using `sudo`. Commands run with root privileges can make significant, irreversible changes to your system if executed incorrectly.
337+
* **Backup Regularly:** Make a habit of backing up important files and configurations, especially before performing major system changes or software installations. This can save you from potential data loss.
338+
230339
## Code Style
231340

232341
**Keep it simple and elegant!**

0 commit comments

Comments
 (0)