0% found this document useful (0 votes)
4 views

Class Note on Linux

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Class Note on Linux

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Class Note - File and Directory Commands

1. ls: List files and directories in the current directory.


ls
ls -l (long format)
ls -a (include hidden files)
ls -lh (long format with human-readable file sizes)
ls -R (list recursively)

2. cd: Change the current directory.


cd /path/to/directory
cd .. (move up one directory)
cd ~ (move to the home directory)

3. pwd: Print the current working directory.

4. mkdir: Create a new directory.


mkdir directory_name

5. rmdir: Remove a directory (only works if it's empty).


rmdir directory_name

6. rm: Remove files or directories. (To use the remove command move back to your root directory “cd ~”)
rm file_name
rm -r directory_name (recursively remove a directory and its contents)
rm -f file_name (force removal without confirmation)
7. cp: Copy files or directories.
cp source_file destination_file
cp -r source_directory destination_directory (recursively copy a directory and its contents)

8. mv: Move or rename files or directories.


mv old_name new_name (rename)
mv file_name /path/to/directory (move file to another directory)

9. touch: Create an empty file or update the timestamp of an existing file.


touch file_name

10. cat: Concatenate and display the content of files.


cat file_name

11. more: Display the content of a file one screen at a time.


more file_name

12. less: Display the content of a file with backward navigation support.
less file_name

13. head: Display the first few lines of a file.


head file_name
head -n 10 file_name (display the first 10 lines)

14. tail: Display the last few lines of a file.


tail file_name
tail -n 10 file_name (display the last 10 lines)
tail -f file_name (follow the file and display new content as it's added.
15. find: Search for files and directories.
find /path/to/search -name "filename_pattern”

16. grep: Search for text patterns in files.


grep "pattern" file_name

17. chmod: Change file permissions.


chmod permissions file_name

18. chown: Change file owner and group.


chown user:group file_name

19. df: Display disk space usage of file systems.


df -h (human-readable format)

20. du: Estimate file space usage.


du -h file_name
du -sh /path/to/directory (summary of a directory's space usage)
Class Note: Linux Package Management

Introduction:
Package management in Linux refers to the system used to install, update, and remove software
packages on a Linux distribution. It is a critical component of the operating system that
simplifies the installation and management of software, ensuring proper dependencies, version
tracking, and system compatibility.

1. Package Managers:
Linux distributions typically use one of two primary package management systems: APT
(Advanced Package Tool), used by Debian and its derivatives, and RPM (RPM Package
Manager), used by Red Hat-based distributions. Other package management systems, such as
DNF (Dandified Yum), have evolved from RPM and are used in newer distributions like Fedora.

2. Common Package Management Commands:

Debian/Ubuntu (APT-based):
- `apt-get`: The traditional command-line tool for package management on Debian-based
systems.
- `apt-get update`: Update the package lists to get the latest information about available
packages.
- `apt-get upgrade`: Upgrade all installed packages to their latest versions.
- `apt-get install package_name`: Install a new package.
- `apt-get remove package_name`: Remove a package (leaving configuration files intact).
- `apt-get purge package_name`: Remove a package and its configuration files.
- `apt-cache search search_term`: Search for packages based on a keyword.

Red Hat/Fedora (RPM/DNF-based):


- `dnf`: The next-generation package manager used by Fedora and newer versions of CentOS and
RHEL.
- `dnf update`: Update all installed packages to their latest versions.
- `dnf install package_name`: Install a new package.
- `dnf remove package_name`: Remove a package (leaving configuration files intact).
- `dnf erase package_name`: Remove a package and its configuration files.
- `dnf search search_term`: Search for packages based on a keyword.

3. Package Repositories:
Package managers use repositories (online software repositories) to fetch and store software
packages. These repositories contain a vast collection of pre-built software packages that are
maintained by the Linux distribution's maintainers and community.

4. Dependency Management:
One of the key advantages of package management is automatic dependency resolution. When
you install a package, the package manager automatically identifies and installs any other
packages required for the software to function correctly.

5. Handling Updates:
Package managers can keep the system up-to-date by regularly checking for updates and
installing the latest versions of software packages, which is essential for maintaining system
security and stability.

6. Software Distribution Format:


Software packages in Linux are typically distributed in a format specific to the distribution (e.g.,
.deb for Debian-based distributions, .rpm for Red Hat-based distributions). This format contains
the necessary files and metadata required for the package manager to install and manage the
software.

7. Graphical Package Managers:


Most Linux distributions also provide graphical package management tools, such as `Synaptic`
(for APT-based systems) and `GNOME Software` (for RPM-based systems), which offer a user-
friendly interface for package management tasks.

Conclusion:
Package management is a fundamental aspect of Linux systems, making it easy for users to
discover, install, and maintain software. It simplifies the process of managing software
dependencies, ensuring the stability and security of the overall system. As a Linux user,
understanding package management is essential for effectively using and maintaining a Linux
distribution.

You might also like