Basic Linux Commands - Part 1
1. man
Most Linux commands come with built-in documentation that you can access using the man command. Simply type man followed by the name of the command you want to learn about, and you’ll get a detailed explanation of how to use it.
Example:
manCopied!
This will open the manual page for the apt command, where you can read about its functions, arguments, and usage examples.
man aptCopied!
2. sudo apt update and sudo apt upgrade
These commands are essential for keeping your system up to date:
sudo apt update: Updates the list of available packages from configured repositories.
sudo apt upgrade: Installs updates for packages already on your system.
Practical Tip: Always run sudo apt update before using sudo apt upgrade to ensure you get the latest updates.
Usage example:
sudo apt updateCopied!
sudo apt upgradeCopied!
3. whoami
If you ever need to know which user you’re logged in as, this command is your solution.
Example:
whoamiCopied!
Running this will display the current user’s name on the screen. Very useful if you work on shared systems or with multiple accounts.
4. uname
The uname command lets you learn more about your operating system and kernel. Here are the most useful arguments:
- uname -s: Kernel name.
- uname -n: Hostname.
- uname -r: Kernel version.
- uname -v: Additional kernel information.
- uname -m: System architecture.
- uname -a: All the information combined.
uname -aCopied!
This command will display something like:
Linux my-computer 5.15.0-73-generic #80-Ubuntu SMP x86_64 GNU/Linux
5. pwd
Don’t know which directory you’re working in? Use pwd to find out. This command prints the full path of the current directory.
Example:
pwdCopied!
Result:
/home/user/MyDocuments
6. mkdir
This command is used to create new directories.
Example:
mkdir folderCopied!
This will create a directory called folder in the current location.
7. touch
With touch, you can quickly create empty files. It’s useful for testing scripts or preparing documents.
Example:
touch fileCopied!
This will create an empty file called file.txt.
8. cd
The cd (change directory) command lets you navigate between directories.
cd Pictures: Changes to the "Pictures" directory.
cd Downloads: Changes to the "Downloads" directory.
cd ..: Moves up to the parent directory.
Practical example:
cd DownloadsCopied!
cdCopied!
9. ls
The ls command lists the contents of the current directory. You can use different arguments to get more details:
ls -l: Shows a detailed list, including permissions, size, and modification dates.
ls -la: Includes hidden files in the list.
Example:
lsCopied!
ls -lCopied!
ls -laCopied!
What’s next?
These commands are just the beginning. In future posts, we’ll explore more tools and features to help you master Linux. Stay tuned!