🖥️ Basic Linux Commands – Trade Theory for COPA
In Linux, the command line is one of the most powerful tools for interacting with the system. Through various Linux commands, you can manage files, monitor system performance, configure settings, and automate tasks. Mastering these basic Linux commands is essential for any Computer Operator and Programming Assistant (COPA) student.
In this section, we will introduce the most commonly used basic Linux commands and explain how they work.
1. Navigating the File System
Linux uses a hierarchical file system. To navigate and manipulate files and directories, you need to know some basic commands:
1.1 pwd
– Print Working Directory
Description: Displays the current directory you are in.
Usage: To see where you are in the file system.
1.2 ls
– List Directory Contents
Description: Lists files and directories in the current directory.
Usage:
You can use flags like
-l
for a long listing format or-a
to show hidden files:
1.3 cd
– Change Directory
Description: Changes the current directory to a specified directory.
Usage: To navigate to a different directory.
cd ..
moves up one directory level.cd ~
takes you to your home directory.
1.4 mkdir
– Make Directory
Description: Creates a new directory.
Usage:
1.5 rmdir
– Remove Directory
Description: Removes an empty directory.
Usage:
2. Managing Files
Linux commands allow you to create, copy, move, and remove files with ease:
2.1 touch
– Create an Empty File
Description: Creates a new, empty file or updates the timestamp of an existing file.
Usage:
2.2 cp
– Copy Files or Directories
Description: Copies files or directories from one location to another.
Usage:
To copy directories recursively, use the
-r
option:
2.3 mv
– Move or Rename Files
Description: Moves files or directories from one location to another. It can also rename files.
Usage:
2.4 rm
– Remove Files
Description: Removes files.
Usage:
To remove directories, use the
-r
option for recursive deletion:To force deletion without confirmation, use
-f
:
3. Viewing and Editing Files
Linux provides commands to view and edit file content:
3.1 cat
– Concatenate and Display Files
Description: Displays the content of a file.
Usage:
3.2 more
– View File Content Page by Page
Description: Displays content of a file one page at a time.
Usage:
3.3 less
– View File Content with Scrolling
Description: Displays content of a file with the ability to scroll.
Usage:
3.4 nano
or vi
– Edit Files
Description: Edits text files.
Usage:
For nano (simple text editor):
For vi (advanced text editor):
4. System Information
To gather important details about your system, Linux provides several commands:
4.1 top
– System Monitoring
Description: Displays system information like CPU usage, memory usage, and active processes.
Usage:
4.2 df
– Disk Space Usage
Description: Displays disk space usage for all mounted file systems.
Usage:
4.3 free
– Memory Usage
Description: Shows available and used memory in the system.
Usage:
4.4 uname
– Kernel Information
Description: Displays system information such as the kernel version.
Usage:
5. Managing Processes
Linux provides several commands to manage and monitor running processes:
5.1 ps
– Display Processes
Description: Displays the currently running processes.
Usage:
For detailed process information:
5.2 kill
– Terminate Processes
Description: Terminates a running process.
Usage:
To forcefully kill a process, use:
6. File Permissions and Ownership
In Linux, file permissions control who can read, write, or execute files:
6.1 chmod
– Change File Permissions
Description: Changes the permissions of a file or directory.
Usage:
Example: Grant read, write, and execute permissions to the user:
6.2 chown
– Change File Ownership
Description: Changes the owner and/or group of a file or directory.
Usage:
7. Searching Files
To find files or content within files, use the following commands:
7.1 find
– Search for Files
Description: Searches for files in a directory hierarchy.
Usage:
7.2 grep
– Search for Content Within Files
Description: Searches for a pattern in the contents of files.
Usage:
Conclusion
Understanding these basic Linux commands will give you a strong foundation for working with Linux systems. As a COPA student, mastering these commands will help you efficiently navigate the system, manage files, monitor processes, and perform essential administrative tasks. The more familiar you become with these commands, the more powerful and flexible your Linux experience will be.