0% found this document useful (0 votes)
8 views9 pages

Free

The document provides an overview of various Linux commands including 'free' for memory usage, 'kill' for terminating processes, 'zip' and 'gzip' for file compression, and 'du' and 'df' for disk usage analysis. It also explains how to change directories with 'cd', sort files with 'sort', and create links with 'ln', detailing the differences between hard and soft links. Each command is accompanied by its syntax and a brief description of its functionality.

Uploaded by

prashantsutar024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Free

The document provides an overview of various Linux commands including 'free' for memory usage, 'kill' for terminating processes, 'zip' and 'gzip' for file compression, and 'du' and 'df' for disk usage analysis. It also explains how to change directories with 'cd', sort files with 'sort', and create links with 'ln', detailing the differences between hard and soft links. Each command is accompanied by its syntax and a brief description of its functionality.

Uploaded by

prashantsutar024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1) free

- The `free` command in Linux is the one that facilitates with providing the overview of
system memory utilization.
- It displays all the details regarding the RAM usage such as how is the total, what is
used, and free memory including
buffers and cached data, aiding in real-time monitoring of memory resources.
- It acts as essential command for administrators and users to assess system
performance, allocate resources effectively, and
identify potential memory-related issues promptly.

Syntax:

free [OPTION]

-k, –kilo --> Displays memory usage in kilobytes (default).


-m, –mega --> Displays memory usage in megabytes.
-g, –giga --> Displays memory usage in gigabytes.
–tera --> Displays memory usage in terabytes.
-h, –human --> Automatically scales all output columns to the shortest three-
digit unit and displays the units (B, K, M, G, T).
-c, –count --> Displays the output ‘c’ number of times; works with the -s
option.

When no option is used then free command produces the columnar output as
shown above where column:

total -->displays the total installed memory (MemTotal and SwapTotal i.e present
in /proc/meminfo).
used --> displays the used memory.
free --> displays the unused memory.
shared --> displays the memory used by tmpfs(Shmen i.e. present in
‘/proc/meminfo’ and displays zero in case not available).
buffers --> displays the memory used by kernel buffers.
cached --> displays the memory used by the page cache and slabs(Cached and
Slab available in ‘/proc/meminfo’).
buffers/cache --> displays the sum of buffers and cache.
2)kill

- It is used to terminate processes manually.


- kill command sends a signal to a process that terminates the process

Syntax :
kill PID

PID = The `kill` command requires the process ID (PID) of the process we want to
terminate.
3) zip

- Zip is used to compress files to reduce file size and is also used as a file package utility.
- Zip is available in many operating systems like Unix, Linux, windows, etc.
- If you have limited bandwidth between two servers and want to transfer the files faster, then
zip the files and transfer them.

Syntax
zip [options] [file_name.zip] [files_names]
==============================================================================
===================================================

4) Gzip

- gzip command compresses files.


- Each single file is compressed into a single file.

Syntax
gzip [Options] [filenames]

==============================================================================
=====================================================

5) gunzip

- is used to compress or expand a file or a list of files in Linux.


- It accepts all the files having extension as
.gz, .z, _z, -gz, -z, .Z, .taz or .tgz

Syntax:
gunzip [Option] [archive name/file name]

6)du - Disk Usage


- It is used to tracking the large files, allowing you to find large files and free up precious disk
space.

Syntax:

$du [options] filename

Example:
suppose there are two file a.txt & b.txt
you want to know the disk usage of these files then u can simply use du command.

$du a.txt b.txt


Output:
18 a.txt
45 b.txt

- in first column displays the file disk usage.

-h --> It is used to produce output in human readable format

$du -h filename
7) df - Disk Filesystem

- It is used to get full summary of available and used disk space usage of file file system on Linux
system.

Syntax:
df [options] filename

-filename - specify filename if you want to kknow that file.

Example:
$df vishal.txt

output:
FileSystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 195714 1512 1955612 1% /vishal

-> df only showed the disk usage details of the file system that contains file vishal.txt

If you enter only df -> df will displays the disk usage information for all mounted file
system

$df

--> -h for human readable format


8) cd - Change directory

- It is used to change your working directory from one to other.

cd dirname

- back to one directory


cd ..
- two times back directory
cd ../..

- go to root directory

cd ~ (Tilt)

Absolute Path
- It defined as the specifying the location/path of the file/dir from root directory
- We can say absolute path is a complete path from start to end.

Relative Path
- It defined as path related to the present working directory
9)sort
SORT command is used to sort a file, arranging the records in a particular order.
SORT command sorts the contents of a text file, line by line.
The sort command is a command-line utility for sorting lines of text files. It supports sorting
alphabetically, in reverse order, by number.
Syntax
sort filename

-r -> Sorts data in reverse order (descending).


-n -> Sorts a file numerically (interprets data as numbers).
-nr -> Sorts a file with numeric data in reverse order. Combines -n and -r options.
-k -> Sorts a table based on a specific column number.
-u -> Sorts and removes duplicate lines, providing a unique sorted list.
-c -> Checks if the file is already sorted and reports any disorder.
10) ln (Link)

- The ‘ln’ command in Linux is a powerful utility that allows you to create links between files
- These links can either be hard links or soft (symbolic) links.

- A link in UNIX/LINUX is a pointer to a file. Like pointers in any programming languages,


links in UNIX/LINUX are pointers pointing to a file or a directory. Creating links is a kind of
shortcuts to access a file.
- Links allow more than one file name to refer to the same file, elsewhere.

There are two types of links :

1. Soft Link or Symbolic links


2. Hard Links

- These links behave differently when the source of the link (what is being linked to) is moved or
removed.
- Symbolic links are not updated (they merely contain a string which is the path name of its
target);
- Hard links always refer to the source, even if moved or removed.

- For example, if we have a file a.txt. If we create a hard link to the file and then delete the file,
we can still access the file using hard link. But if we create a soft link of the file and then delete
the file,
we can’t access the file through soft link and soft link becomes dangling.
- Basically hard link increases reference count of a location while soft links work as a shortcut
(like in Windows)
1. Soft Link or Symbolic links

- A soft link is similar to the file shortcut feature which is used in Windows Operating systems.
- Each soft linked file contains a separate Inode value that points to the original file.
- As similar to hard links, any changes to the data in either file is reflected in the other.
Soft links can be linked across different file systems, although if the original file is deleted or
moved,
the soft linked file will not work correctly (called hanging link).

- ls -l command shows all links with first column value l? and the link points to original file.
- Soft Link contains the path for original file and not the contents.
- Removing soft link doesn’t affect anything but removing original file, the link becomes
“dangling” link which points to nonexistent file.
- A soft link can link to a directory.
- If we change the name of the original file then all the soft links for that file become dangling
i.e. they are worthless now.
- Link across file systems: If you want to link files across the file systems, you can only use
symlinks/soft links.

Syntax
$ ln -s [original filename] [link name]

2. Hard Links
- Each hard linked file is assigned the same Inode value as the original, therefore they reference
the same physical file location.
- Hard links more flexible and remain linked even if the original or linked files are moved
throughout the file system.
- ls -l command shows all the links with the link column shows number of links.
- Links have actual file contents
- Removing any link, just reduces the link count, but doesn’t affect other links.
- Even if we change the filename of the original file then also the hard links properly work.
- We cannot create a hard link for a directory to avoid recursive loops.
- If original file is removed then the link will still show the content of the file.
- The size of any of the hard link file is same as the original file and
if we change the content in any of the hard links then size of all hard link files are updated.
- The disadvantage of hard links is that it cannot be created for files on different file systems
and it cannot be created for special files or directories.

Syntax
$ ln [original filename] [link name]

You might also like