Linux

Getting Started with Linux: Basic Commands and Terminal Usage

For those new to Linux, getting comfortable with the terminal and some basic commands can be intimidating. However, learning just a few basic commands can greatly increase your ability to navigate and use Linux systems. In this post, I'll go over some Linux terminology and provide examples of common Linux commands.

The Linux Terminal

The terminal provides a command line interface to the Linux operating system. It's a text-based interface, not graphical. You type commands which the computer then executes. Think old-school green text on black background.

When you open a terminal, it starts at your "home" directory. This is where your personal files are stored. The tilde ~ symbol refers to your home directory.

The dollar sign $ represents a regular user prompt. A pound sign # represents root, the administrative user.


The keyboard shortcut to open a terminal Ctrl + Alt + T


Basic Linux Commands

cd - Change directory. Navigate to a new directory.

cd Documents

cd .. (go up one directory) cd ~ (go home)


ls - List the contents of a directory.

ls

ls Documents (list contents of Documents directory) ls -l (long format listing)


mkdir - Make a new directory.

mkdir Projects


rm - Remove a file.

rm file.txt


cat - Output file contents to the terminal.

cat file.txt


sudo - Run a command with administrative privileges.

sudo apt update


grep - Search for text patterns in files.

grep "search phrase" file.txt


cp - Copy files and directories.

cp file.txt file2.txt

cp -r folder1 folder2 (copy folder1 to folder2)


mv - Move or rename files and directories.

mv file.txt documents/ mv file.txt newname.txt


touch - Create a new empty file.

touch testfile.txt


nano - Simple text editor for the terminal.

nano testfile.txt


chmod - Change file permissions.

chmod 600 file.txt chmod +x script.sh (make script executable)


ssh - Securely log into remote machine.

ssh user@192.168.1.10


ping - Check network connectivity to a host.

ping google.com


kill - Terminate a process by its PID.

kill 4509


tar - Archive files into a .tar file.

tar -cvf archive.tar folder/


wget - Download a file from the web.

wget https://example.com/file.zip


man - Get help for a command.

man ls




No comments:

Post a Comment