docs/guides/linux-basics.md

60 lines
1.7 KiB
Markdown
Raw Normal View History

2023-06-27 07:54:20 +00:00
---
title: The basics of Linux
description: Simple examples showing you around Linux
published: true
date: 2023-06-27T07:54:18.672Z
tags: linux, server
editor: markdown
dateCreated: 2023-06-27T07:54:18.672Z
---
2023-06-27 08:00:08 +00:00
# Linux Basics
This guide provides a brief introduction to Linux, including basic commands and concepts.
## Navigating the filesystem
- Change a directory: `cd <directory>`
- List files in a directory: `ls`
- List files in a directory (including hidden files): `ls -a`
- Getting the current directory: `pwd`
- Going back a directory: `cd ..`
## Managing Files and Directories
- Create a new directory: `mkdir <directory>`
- Create a new file: `touch <file>`
- Copy a file: `cp <file> <new-file>`
- Remove a file: `rm <file>`
- Remove a directory: `rm -r <directory>`
## File Permissions
- Change file permissions: `chmod <permissions> <file>`
- Change file ownership: `chown <user> <file>`
- Change file ownership (recursively): `chown -R <user> <directory>`
- View file permissions: `ls -l <file>`
## Text Processing
- View a file: `cat <file>`
- View a file (with line numbers): `cat -n <file>`
- Get the beginning of a file: `head <file>`
- Get the end of a file: `tail <file>`
## Package Management (Ubuntu)
- Update package lists: `sudo apt update`
- Install a package: `sudo apt install <package>`
- Purge a package: `sudo apt purge <package>`
- Remove a package: `sudo apt remove <package>`
- Search for a package: `apt search <package>`
- Upgrade packages: `sudo apt upgrade`
## File Compression and Archiving
- Create a tar archive: `tar -cvf <archive.tar> <file>`
- Extract a tar archive: `tar -xvf <archive.tar>`
- Create a zip archive: `zip <archive.zip> <file>`
- Extract a zip archive: `unzip <archive.zip>`