0% found this document useful (0 votes)
41 views4 pages

Linux - 1.2

The document provides an overview of the Linux terminal, detailing its function as a command line interface for interacting with the operating system. It includes a comprehensive list of essential Linux commands for file management, process monitoring, and system information, along with examples for each command. Additionally, it explains the major directories in a Linux system and their purposes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views4 pages

Linux - 1.2

The document provides an overview of the Linux terminal, detailing its function as a command line interface for interacting with the operating system. It includes a comprehensive list of essential Linux commands for file management, process monitoring, and system information, along with examples for each command. Additionally, it explains the major directories in a Linux system and their purposes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Understanding the Linux Terminal


The Linux terminal (also known as the command line interface or CLI) is a text-
based interface used to interact with the operating system. In this interface, you
can run commands to perform tasks like navigating directories, managing files, and
installing software.

Linux:
Amazon Linux 2
Ubuntu (various versions)
Red Hat Enterprise Linux (RHEL)
CentOS
Debian
SUSE Linux
FreeBSD
Windows:
Windows Server (2012, 2016, 2019, 2022)

2.Linux Commands
Navigating the File System:
pwd (Print Working Directory)
Usage: Displays the current directory you're in.
Example:
$ pwd
/home/user

ls (List)
Usage: Lists files and directories in the current directory.
Example:
$ ls
Desktop Documents Downloads Pictures
ls -l: Detailed list, showing permissions, size, and date.
ls -a: Show hidden files.

cd (Change Directory)
Usage: Changes the current directory to another one.
Example:
$ cd /home/user/Documents

cd ..
Usage: Moves up one directory level.
Example:
$ cd ..

Working with Files:


touch (Create a file)
Usage: Creates an empty file.
Example:
$ touch newfile.txt

cat (Concatenate and display content of a file)


Usage: Displays the content of a file.
Example:
$ cat newfile.txt

cp ( a file or directory)
Usage: Copies a file or directory from one location to another.
Example:
$ cp file1.txt /home/user/Documents/
mv (Move or Rename a file or directory)
Usage: Moves or renames a file or directory.
Example:
$ mv oldfile.txt newfile.txt

rm (Remove a file)
Usage: Deletes a file.
Example:
$ rm unwantedfile.txt

rmdir (Remove an empty directory)


Usage: Removes an empty directory.
Example:
$ rmdir emptydir

rm -r (Remove a directory and its contents)


Usage: Deletes a directory and all of its contents.
Example:
$ rm -r foldername

Viewing and Editing Files:


vi (Text editor)
Usage: Opens a text editor for creating or editing files.
Example:
$ nano myfile.txt
Tips:
Use CTRL + O to save the file.
Use CTRL + X to exit.

vi or vim (Advanced text editor)


Usage: Opens the vi or vim text editor (more advanced).
Example:
$ vi myfile.txt
Viewing Process Information:

ps (Process Status)
Usage: Displays the currently running processes.
Example:
$ ps

top (Task Manager)


Usage: Displays running processes and resource usage in real-time.
Example:
$ top

kill (Terminate a process)


Usage: Ends a running process by its PID (Process ID).
Example:
$ kill 1234
File Permissions:

chmod (Change file permissions)


Usage: Modifies the permissions of a file or directory.
Example:
$ chmod +x script.sh

chown (Change file ownership)


Usage: Changes the owner and/or group of a file or directory.
Example:
$ chown user:group myfile.txt

Searching and Finding Files:


find (Search for files and directories)
Usage: Searches for files and directories within a specified path.
Example:
$ find /home/user -name "file*.txt"

grep (Search for text patterns in files)


Usage: Searches for a pattern in files.
Example:
$ grep "pattern" filename.txt

System Information:
df (Disk space usage)
Usage: Displays information about disk space usage.
Example:
$ df -h
free (Memory usage)

Usage: Shows memory usage (RAM).


Example:
$ free -h

uptime (System uptime)


Usage: Displays how long the system has been running.
Example:
$ uptime

hostname (Show or set the system’s hostname)

Usage: Displays the system’s hostname.


Example:
$ hostname

Explanation of Major Directories:


/: The root directory. All files and directories start from here.

/bin: Contains essential system binaries (programs) that are used by both the
system and users.

/boot: Contains boot loader files like the kernel and initial RAM disk images.

/dev: Contains device files that represent hardware devices (e.g., hard drives, USB
drives).

/etc: Contains configuration files for the system and installed software.

/home: Contains the personal directories of users. Each user has their own
directory here.

/lib: Contains shared libraries needed for system programs to run.

/media: Mount points for removable media (like CDs, DVDs, USB drives).
/mnt: Temporary mount points for file systems, like mounted network drives.

/opt: Optional software packages installed on the system.

/proc: Virtual filesystem providing system information, like CPU and memory stats.

/root: The root user's home directory (not to be confused with /).

/run: Stores runtime data (temporary files, system logs).

/sbin: Contains system binaries for administrative tasks, typically used by root.

/srv: Contains data for services provided by the system, like web servers.

/sys: Virtual filesystem that provides information about kernel and devices.

/tmp: Temporary files that can be deleted on reboot.

/usr: Contains user applications, libraries, and documentation.

/var: Variable data like logs, mail, and other files that change over time.

You might also like