Get full Access to Website Content, WebShark packet capture tool and Proximity Download. Purchase
⛶ Night Mode

Linux File System

A Linux file system is a structured collection of files on a disk drive or a partition. A partition is a segment of memory and contains some specific data. In our machine, there can be various partitions of the memory. Generally, every partition contains a file system.

The general-purpose computer system needs to store data systematically so that we can easily access the files in less time. It stores the data on hard disks (HDD) or some equivalent storage type. There may be below reasons for maintaining the file system:

Linux File System Component

The linux file system contains the following sections:

  • The root directory (/)
  • A specific data storage format (EXT3, EXT4, BTRFS, XFS and so on)
  • A partition or logical volume having a particular file system.

Linux File System Structure

Linux file system has a hierarchal file structure as it contains a root directory and its subdirectories. All other directories can be accessed from the root directory. A partition usually has only one file system, but it may have more than one file system. Linux file system contains two-part file system software implementation architecture. Consider the below image:

linux-file-system

The file system requires an API (Application programming interface) to access the function calls to interact with file system components like files and directories. API facilitates tasks such as creating, deleting, and copying the files. It facilitates an algorithm that defines the arrangement of files on a file system.

Directory Structure

The directory structure of Linux is well-documented and defined in the Linux FHS (Filesystem Hierarchy Standard). Referencing those directories if accessing them is achieved via the sequentially deeper names of the directory linked by '/' forward slash like /var/spool/mail and /var/log

These are known as paths.

root@ipxpy-debian-server:/# ls -lh
total 60K
lrwxrwxrwx 1 root root 7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x 4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x 14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x 70 root root 4.0K Sep 11 17:48 etc
drwxr-xr-x 4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx 1 root root 7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Aug 14 21:37 libx32 -> usr/libx32
drwx------ 2 root root 16K Aug 14 21:36 lost+found
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 133 root root 0 Sep 11 17:48 proc
drwx------ 3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x 21 root root 620 Sep 11 17:49 run
lrwxrwxrwx 1 root root 8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x 13 root root 0 Sep 11 17:48 sys
drwxrwxrwt 10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x 14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x 11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#

  • / (root filesystem): It is the top-level filesystem directory. It must include every file needed to boot the Linux system before another filesystem is mounted. Every other filesystem is mounted on a well-defined and standard mount point because of the root filesystem directories after the system is started.
  • /boot: It includes the static kernel and bootloader configuration and executable files needed to start a Linux computer.
  • /bin: This directory includes user executable files.
  • /dev: It includes the device file for all hardware devices connected to the system. These aren’t device drivers; instead, they are files that indicate all devices on the system and provide access to these devices.
  • /etc: It includes the local system configuration files for the host system.
  • /lib: It includes shared library files that are needed to start the system.
  • /home: The home directory storage is available for user files. All users have a subdirectory inside /home.
  • /mnt: It is a temporary mount point for basic filesystems that can be used at the time when the administrator is working or repairing a filesystem.
  • /media: A place for mounting external removable media devices like USB thumb drives that might be linked to the host.
  • /opt: It contains optional files like vendor supplied application programs that must be placed here.
  • /root: It’s the home directory for a root user. Keep in mind that it’s not the ‘/’ (root) file system.
  • /tmp: It is a temporary directory used by the OS and several programs for storing temporary files. Also, users may temporarily store files here. Remember that files may be removed without prior notice at any time in this directory.
  • /sbin: These are system binary files. They are executables utilized for system administration.
  • /usr: They are read-only and shareable files, including executable libraries and binaries, man files, and several documentation types.
  • /var: Here, variable data files are saved. It can contain things such as MySQL, log files, other database files, email inboxes, web server data files, and much more.

Linux File System Features

In Linux, the file system creates a tree structure. All the files are arranged as a tree and its branches. The topmost directory called the root (/) directory. All other directories in Linux can be accessed from the root directory.

Some key features of linux file system are as following:

  • Specifying paths: Linux does not use the backslash (\) to separate the components; it uses forward slash (/) as an alternative. For example, as in Windows, the data may be stored in C:\ My Documents\ Work, whereas, in Linux, it would be stored in /home/ My Document/ Work.
  • Partition, Directories, and Drives: Linux does not use drive letters to organize the drive as Windows does. In Linux, we cannot tell whether we are addressing a partition, a network device, or an “ordinary” directory and a Drive.
  • Case Sensitivity: Linux file system is case sensitive. It distinguishes between lowercase and uppercase file names. Such as, there is a difference between test.txt and Test.txt in Linux. This rule is also applied for directories and Linux commands.
  • File Extensions: In Linux, a file may have the extension ‘.txt,’ but it is not necessary that a file should have a file extension. While working with Shell, it creates some problems for the beginners to differentiate between files and directories. If we use the graphical file manager, it symbolizes the files and folders.
  • Hidden files: Linux distinguishes between standard files and hidden files, mostly the configuration files are hidden in Linux OS. Usually, we don’t need to access or read the hidden files. The hidden files in Linux are represented by a dot (.) before the file name (e.g., .ignore). To access the files, we need to change the view in the file manager or need to use a specific command in the shell.

Types of Linux File System

When we install the Linux operating system, Linux offers many file systems such as Ext, Ext2, Ext3, Ext4, JFS, ReiserFS, XFS, btrfs, and swap.

Linux File Commands

Linux provides a variety of file commands that allow you to manipulate files and directories in the file system. Here are some commonly used Linux file commands:

  1. ls: List files and directories in a directory. els
  2. pwd: Print the current working directory. pwd
  3. cd: Change the current directory. cd /path/to/directory
  4. touch: Create an empty file or update the timestamp of an existing file. touch filename
  5. mkdir: Create a new directory. mkdir directoryname
  6. rmdir: Remove a directory (only if it’s empty). rmdir directoryname
  7. rm: Remove files or directories. rm filename rm -r directoryname # Use -r or -rf to remove directories and their contents recursively (be careful).
  8. cp: Copy files and directories. cp source destination cp -r sourcedir destination # To copy directories and their contents recursively.
  9. mv: Move or rename files and directories. mv oldname newname # To rename a file or directory. mv source destination # To move a file or directory to another location.
  10. cat: Concatenate and display the content of a file. cat filename
  11. more and less: Display text files one screen at a time. You can scroll through the file using the arrow keys. more filename less filename
  12. head and tail: Display the beginning or end of a file. head filename # Display the first few lines. tail filename # Display the last few lines.
  13. ln: Create hard or symbolic (soft) links to files. ln -s source linkname # Create a symbolic link.
  14. chmod: Change file permissions. chmod permissions filename
  15. chown: Change file ownership. chown owner:group filename
  16. find: Search for files and directories in a directory hierarchy. find /path/to/search -name filename
  17. grep: Search for text patterns in files. grep pattern filename
  18. wc: Count the number of lines, words, or characters in a file. wc filename
  19. file: Determine the file type. file filename
  20. stat: Display file or file system status. stat filename
  21. du: Display disk usage of files and directories. du -h directory # -h for human-readable output.

These are some of the essential Linux file commands that can help you manage files and directories efficiently in a Linux-based system. Remember to use these commands carefully, especially when dealing with the removal or modification of files and directories, as they can have significant consequences on your system.

Linux File Commands Example

List Help

root@ipxpy-debian-server:/# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      with -l, scale sizes by SIZE when printing them;
                               e.g., '--block-size=M'; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~
  -c                         with -lt: sort by, and show, ctime (time of last
                               modification of file status information);
                               with -l: show ctime and sort by name;
                               otherwise: sort by ctime, newest first
  -C                         list entries by columns
      --color[=WHEN]         colorize the output; WHEN can be 'always' (default
                               if omitted), 'auto', or 'never'; more info below
  -d, --directory            list directories themselves, not their contents
  -D, --dired                generate output designed for Emacs' dired mode
  -f                         do not sort, enable -aU, disable -ls --color
  -F, --classify             append indicator (one of */=>@|) to entries
      --file-type            likewise, except do not append '*'
      --format=WORD          across -x, commas -m, horizontal -x, long -l,
                               single-column -1, verbose -l, vertical -C
      --full-time            like -l --time-style=full-iso
  -g                         like -l, but do not list owner
      --group-directories-first
                             group directories before files;
                               can be augmented with a --sort option, but any
                               use of --sort=none (-U) disables grouping
  -G, --no-group             in a long listing, don't print group names
  -h, --human-readable       with -l and -s, print sizes like 1K 234M 2G etc.
      --si                   likewise, but use powers of 1000 not 1024
  -H, --dereference-command-line
                             follow symbolic links listed on the command line
      --dereference-command-line-symlink-to-dir
                             follow each command line symbolic link
                               that points to a directory
      --hide=PATTERN         do not list implied entries matching shell PATTERN
                               (overridden by -a or -A)
      --hyperlink[=WHEN]     hyperlink file names; WHEN can be 'always'
                               (default if omitted), 'auto', or 'never'
      --indicator-style=WORD  append indicator with style WORD to entry names:
                               none (default), slash (-p),
                               file-type (--file-type), classify (-F)
  -i, --inode                print the index number of each file
  -I, --ignore=PATTERN       do not list implied entries matching shell PATTERN
  -k, --kibibytes            default to 1024-byte blocks for disk usage;
                               used only with -s and per directory totals
  -l                         use a long listing format
  -L, --dereference          when showing file information for a symbolic
                               link, show information for the file the link
                               references rather than for the link itself
  -m                         fill width with a comma separated list of entries
  -n, --numeric-uid-gid      like -l, but list numeric user and group IDs
  -N, --literal              print entry names without quoting
  -o                         like -l, but do not list group information
  -p, --indicator-style=slash
                             append / indicator to directories
  -q, --hide-control-chars   print ? instead of nongraphic characters
      --show-control-chars   show nongraphic characters as-is (the default,
                               unless program is 'ls' and output is a terminal)
  -Q, --quote-name           enclose entry names in double quotes
      --quoting-style=WORD   use quoting style WORD for entry names:
                               literal, locale, shell, shell-always,
                               shell-escape, shell-escape-always, c, escape
                               (overrides QUOTING_STYLE environment variable)
  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
  -s, --size                 print the allocated size of each file, in blocks
  -S                         sort by file size, largest first
      --sort=WORD            sort by WORD instead of name: none (-U), size (-S),
                               time (-t), version (-v), extension (-X)
      --time=WORD            change the default of using modification times;
                               access time (-u): atime, access, use;
                               change time (-c): ctime, status;
                               birth time: birth, creation;
                             with -l, WORD determines which time to show;
                             with --sort=time, sort by WORD (newest first)
      --time-style=TIME_STYLE  time/date format with -l; see TIME_STYLE below
  -t                         sort by time, newest first; see --time
  -T, --tabsize=COLS         assume tab stops at each COLS instead of 8
  -u                         with -lt: sort by, and show, access time;
                               with -l: show access time and sort by name;
                               otherwise: sort by access time, newest first
  -U                         do not sort; list entries in directory order
  -v                         natural sort of (version) numbers within text
  -w, --width=COLS           set output width to COLS.  0 means no limit
  -x                         list entries by lines instead of by columns
  -X                         sort alphabetically by entry extension
  -Z, --context              print any security context of each file
  -1                         list one file per line.  Avoid '\n' with -q or -b
      --help     display this help and exit
      --version  output version information and exit

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.

The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or +FORMAT.
FORMAT is interpreted like in date(1).  If FORMAT is FORMAT1<newline>FORMAT2,
then FORMAT1 applies to non-recent files and FORMAT2 to recent files.
TIME_STYLE prefixed with 'posix-' takes effect only outside the POSIX locale.
Also the TIME_STYLE environment variable sets the default style to use.

Using color to distinguish file types is disabled both by default and
with --color=never.  With --color=auto, ls emits color codes only when
standard output is connected to a terminal.  The LS_COLORS environment
variable can change the settings.  Use the dircolors command to set it.

Exit status:
 0  if OK,
 1  if minor problems (e.g., cannot access subdirectory),
 2  if serious trouble (e.g., cannot access command-line argument).

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/ls>
or available locally via: info '(coreutils) ls invocation'
root@ipxpy-debian-server:/#

List Files in Human Readable Format[-h] and a Long Listing Format [-l]

root@ipxpy-debian-server:/# ls -lh
total 64K
lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x  70 root root 4.0K Sep 11 18:11 etc
drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
drwx------   2 root root  16K Aug 14 21:36 lost+found
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 133 root root    0 Sep 11 17:48 proc
drwx------   3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x  21 root root  620 Sep 11 17:49 run
lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#

List Files with its inode[indexed node] details [index number]

root@ipxpy-debian-server:/# ls -lh -i
total 64K
    12 lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
393217 drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
     1 drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
131197 drwxr-xr-x  70 root root 4.0K Sep 11 18:34 etc
131233 drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
    14 lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
    15 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
    16 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
    17 lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
    11 drwx------   2 root root  16K Aug 14 21:36 lost+found
131407 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
131402 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
131404 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
     1 dr-xr-xr-x 134 root root    0 Sep 11 17:48 proc
131235 drwx------   3 root root 4.0K Sep 11 17:42 root
     1 drwxr-xr-x  21 root root  620 Sep 11 17:49 run
    13 lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
131403 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
     1 dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
262145 drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
131238 drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
393219 drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
131075 drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#

Sorted List Files based on size / ascending and descending order

root@ipxpy-debian-server:/# ls -lh -i --sort=s
total 64K
    11 drwx------   2 root root  16K Aug 14 21:36 lost+found
393217 drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
131197 drwxr-xr-x  70 root root 4.0K Sep 11 18:34 etc
131233 drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
131407 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
131402 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
131404 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
131235 drwx------   3 root root 4.0K Sep 11 17:42 root
131403 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
262145 drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
131238 drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
393219 drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
131075 drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
     1 drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
     1 drwxr-xr-x  21 root root  620 Sep 11 17:49 run
    17 lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
    15 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
    16 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
    13 lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
    12 lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
    14 lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
     1 dr-xr-xr-x 134 root root    0 Sep 11 17:48 proc
     1 dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
root@ipxpy-debian-server:/#
root@ipxpy-debian-server:/# ls -lh -i --sort=s --reverse
total 64K
     1 dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
     1 dr-xr-xr-x 134 root root    0 Sep 11 17:48 proc
    14 lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
    12 lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
    13 lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
    16 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
    15 lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
    17 lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
     1 drwxr-xr-x  21 root root  620 Sep 11 17:49 run
     1 drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
131075 drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
393219 drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
131238 drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
262145 drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
131403 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
131235 drwx------   3 root root 4.0K Sep 11 17:42 root
131404 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
131402 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
131407 drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
131233 drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
131197 drwxr-xr-x  70 root root 4.0K Sep 11 18:34 etc
393217 drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
    11 drwx------   2 root root  16K Aug 14 21:36 lost+found
root@ipxpy-debian-server:/#
root@ipxpy-debian-server:/# pwd

/
root@ipxpy-debian-server:/# cd /etc
root@ipxpy-debian-server:/etc# pwd

/etc
root@ipxpy-debian-server:/etc#

Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.

root@ipxpy-debian-server:/etc# cd

root@ipxpy-debian-server:~# cd /
root@ipxpy-debian-server:/# cd /etc
root@ipxpy-debian-server:/etc# cd ..

.. is processed by removing the immediately previous pathname component
back to a slash or the beginning of DIR.

root@ipxpy-debian-server:/# mkdir testdir
root@ipxpy-debian-server:/# ls -lh
total 68K
lrwxrwxrwx 1 root root 7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x 4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x 14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x 70 root root 4.0K Sep 11 19:04 etc
drwxr-xr-x 4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx 1 root root 7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Aug 14 21:37 libx32 -> usr/libx32
drwx------ 2 root root 16K Aug 14 21:36 lost+found
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 136 root root 0 Sep 11 17:48 proc
drwx------ 3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x 21 root root 620 Sep 11 17:49 run
lrwxrwxrwx 1 root root 8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x 13 root root 0 Sep 11 17:48 sys
drwxr-xr-x 2 root root 4.0K Sep 11 18:30 test
drwxr-xr-x 2 root root 4.0K Sep 11 19:08 testdir
drwxrwxrwt 10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x 14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x 11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#
root@ipxpy-debian-server:/# rmdir testdir
root@ipxpy-debian-server:/#

root@ipxpy-debian-server:/# rmdir testdir
rmdir: failed to remove 'testdir': Directory not empty
root@ipxpy-debian-server:/#

root@ipxpy-debian-server:/# rm --help
Usage: rm [OPTION]... [FILE]...
Remove (unlink) the FILE(s).

  -f, --force           ignore nonexistent files and arguments, never prompt
  -i                    prompt before every removal
  -I                    prompt once before removing more than three files, or
                          when removing recursively; less intrusive than -i,
                          while still giving protection against most mistakes
      --interactive[=WHEN]  prompt according to WHEN: never, once (-I), or
                          always (-i); without WHEN, prompt always
      --one-file-system  when removing a hierarchy recursively, skip any
                          directory that is on a file system different from
                          that of the corresponding command line argument
      --no-preserve-root  do not treat '/' specially
      --preserve-root[=all]  do not remove '/' (default);
                              with 'all', reject any command line argument
                              on a separate device from its parent
  -r, -R, --recursive   remove directories and their contents recursively
  -d, --dir             remove empty directories
  -v, --verbose         explain what is being done
      --help     display this help and exit
      --version  output version information and exit

By default, rm does not remove directories.  Use the --recursive (-r or -R)
option to remove each listed directory, too, along with all of its contents.

To remove a file whose name starts with a '-', for example '-foo',
use one of these commands:
  rm -- -foo

  rm ./-foo

Note that if you use rm to remove a file, it might be possible to recover
some of its contents, given sufficient expertise and/or time.  For greater
assurance that the contents are truly unrecoverable, consider using shred.

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/rm>
or available locally via: info '(coreutils) rm invocation'
root@ipxpy-debian-server:/#

rm filename

root@ipxpy-debian-server:/testdir# ls -lh
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:10 test.txt
-rw-r--r-- 1 root root 0 Sep 11 19:13 text2.txt
root@ipxpy-debian-server:/testdir# rm text2.txt
root@ipxpy-debian-server:/testdir# ls -lh
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:10 test.txt
root@ipxpy-debian-server:/testdir#

rm -r directoryname # Use -r or -rf to remove directories and their contents recursively (be careful).

root@ipxpy-debian-server:/# ls -lh
total 68K
lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x  70 root root 4.0K Sep 11 19:04 etc
drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
drwx------   2 root root  16K Aug 14 21:36 lost+found
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 136 root root    0 Sep 11 17:48 proc
drwx------   3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x  21 root root  620 Sep 11 19:15 run
lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
drwxr-xr-x   2 root root 4.0K Sep 11 19:18 testdir
drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/# rm -r testdir
root@ipxpy-debian-server:/# ls -lh
total 64K
lrwxrwxrwx   1 root root    7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x   4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x  14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x  70 root root 4.0K Sep 11 19:04 etc
drwxr-xr-x   4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx   1 root root    7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx   1 root root    9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx   1 root root   10 Aug 14 21:37 libx32 -> usr/libx32
drwx------   2 root root  16K Aug 14 21:36 lost+found
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 136 root root    0 Sep 11 17:48 proc
drwx------   3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x  21 root root  620 Sep 11 19:15 run
lrwxrwxrwx   1 root root    8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x   2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x  13 root root    0 Sep 11 17:48 sys
drwxr-xr-x   2 root root 4.0K Sep 11 18:30 test
drwxrwxrwt  10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x  14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x  11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#


root@ipxpy-debian-server:/# ls -lh
total 68K
lrwxrwxrwx 1 root root 7 Aug 14 21:37 bin -> usr/bin
drwxr-xr-x 4 root root 4.0K Aug 14 21:44 boot
drwxr-xr-x 14 root root 2.8K Sep 11 17:48 dev
drwxr-xr-x 70 root root 4.0K Sep 11 19:04 etc
drwxr-xr-x 4 root root 4.0K Sep 11 15:04 home
lrwxrwxrwx 1 root root 7 Aug 14 21:37 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Aug 14 21:37 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Aug 14 21:37 libx32 -> usr/libx32
drwx------ 2 root root 16K Aug 14 21:36 lost+found
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 media
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 mnt
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 opt
dr-xr-xr-x 136 root root 0 Sep 11 17:48 proc
drwx------ 3 root root 4.0K Sep 11 17:42 root
drwxr-xr-x 21 root root 620 Sep 11 17:49 run
lrwxrwxrwx 1 root root 8 Aug 14 21:37 sbin -> usr/sbin
drwxr-xr-x 2 root root 4.0K Aug 14 21:37 srv
dr-xr-xr-x 13 root root 0 Sep 11 17:48 sys
drwxr-xr-x 2 root root 4.0K Sep 11 18:30 test
drwxr-xr-x 2 root root 4.0K Sep 11 19:08 testdir
drwxrwxrwt 10 root root 4.0K Sep 11 17:48 tmp
drwxr-xr-x 14 root root 4.0K Aug 14 21:37 usr
drwxr-xr-x 11 root root 4.0K Aug 14 21:37 var
root@ipxpy-debian-server:/#

root@ipxpy-debian-server:/# cd testdir1
root@ipxpy-debian-server:/testdir1# touch testdir1_text.txt
root@ipxpy-debian-server:/testdir1# ls -lh
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:21 testdir1_text.txt
root@ipxpy-debian-server:/testdir1# cp testdir1_text.txt /testdir2/testdir2_text.txt
root@ipxpy-debian-server:/testdir1# cd ..
root@ipxpy-debian-server:/# cd /testdir2
root@ipxpy-debian-server:/testdir2# ls -lh
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:21 testdir2_text.txt
root@ipxpy-debian-server:/testdir2#
root@ipxpy-debian-server:/testdir1# cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
  or:  cp [OPTION]... SOURCE... DIRECTORY
  or:  cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
  -a, --archive                same as -dR --preserve=all
      --attributes-only        don't copy the file data, just the attributes
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
      --copy-contents          copy contents of special files when recursive
  -d                           same as --no-dereference --preserve=links
  -f, --force                  if an existing destination file cannot be
                                 opened, remove it and try again (this option
                                 is ignored when the -n option is also used)
  -i, --interactive            prompt before overwrite (overrides a previous -n
                                  option)
  -H                           follow command-line symbolic links in SOURCE
  -l, --link                   hard link files instead of copying
  -L, --dereference            always follow symbolic links in SOURCE
  -n, --no-clobber             do not overwrite an existing file (overrides
                                 a previous -i option)
  -P, --no-dereference         never follow symbolic links in SOURCE
  -p                           same as --preserve=mode,ownership,timestamps
      --preserve[=ATTR_LIST]   preserve the specified attributes (default:
                                 mode,ownership,timestamps), if possible
                                 additional attributes: context, links, xattr,
                                 all
      --no-preserve=ATTR_LIST  don't preserve the specified attributes
      --parents                use full source file name under DIRECTORY
  -R, -r, --recursive          copy directories recursively
      --reflink[=WHEN]         control clone/CoW copies. See below
      --remove-destination     remove each existing destination file before
                                 attempting to open it (contrast with --force)
      --sparse=WHEN            control creation of sparse files. See below
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -s, --symbolic-link          make symbolic links instead of copying
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 copy only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -x, --one-file-system        stay on this file system
  -Z                           set SELinux security context of destination
                                 file to default type
      --context[=CTX]          like -Z, or if CTX is specified then set the
                                 SELinux or SMACK security context to CTX
      --help     display this help and exit
      --version  output version information and exit

By default, sparse SOURCE files are detected by a crude heuristic and the
corresponding DEST file is made sparse as well.  That is the behavior
selected by --sparse=auto.  Specify --sparse=always to create a sparse DEST
file whenever the SOURCE file contains a long enough sequence of zero bytes.
Use --sparse=never to inhibit creation of sparse files.

When --reflink[=always] is specified, perform a lightweight copy, where the
data blocks are copied only when modified.  If this is not possible the copy
fails, or if --reflink=auto is specified, fall back to a standard copy.
Use --reflink=never to ensure a standard copy is performed.

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

As a special case, cp makes a backup of SOURCE when the force and backup
options are given and SOURCE and DEST are the same name for an existing,
regular file.

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/cp>
or available locally via: info '(coreutils) cp invocation'
root@ipxpy-debian-server:/testdir1#
root@ipxpy-debian-server:/# mv --help
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     display this help and exit
      --version  output version information and exit

The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable.  Here are the values:

  none, off       never make backups (even if --backup is given)
  numbered, t     make numbered backups
  existing, nil   numbered if numbered backups exist, simple otherwise
  simple, never   always make simple backups

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/mv>
or available locally via: info '(coreutils) mv invocation'
root@ipxpy-debian-server:/#
root@ipxpy-debian-server:/# cd testdir1
root@ipxpy-debian-server:/testdir1# ls -lh
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:21 testdir1_text.txt
root@ipxpy-debian-server:/testdir1# mv testdir1_text.txt /testdir2/testdir2_text.txt
root@ipxpy-debian-server:/testdir1# mv testdir1_text.txt /testdir2/testdir2_text.txt -v
mv: cannot stat 'testdir1_text.txt': No such file or directory
root@ipxpy-debian-server:/testdir1# touch testdir1_text.txt
root@ipxpy-debian-server:/testdir1# mv testdir1_text.txt /testdir2/testdir2_text.txt -v
renamed 'testdir1_text.txt' -> '/testdir2/testdir2_text.txt'
root@ipxpy-debian-server:/testdir1# ls -lh
total 0
root@ipxpy-debian-server:/testdir1#

The chmod command in Linux is used to change the permissions (mode) of files and directories. File permissions control who can access, modify, or execute a file or directory. The chmod command allows you to specify the desired permissions using symbolic or numeric representations.

To check ownership of a file or files inside a directory run ls -l command.

root@ipxpy-debian-server:/testdir1# ls -l
total 0
-rw-r--r-- 1 root root 0 Sep 11 19:47 nefile1
-rw-r--r-- 1 root root 0 Sep 11 19:47 nefile2
-rw-r--r-- 1 root root 0 Sep 11 19:47 nefile3
-rw-r--r-- 1 root root 0 Sep 11 19:47 nefile4
root@ipxpy-debian-server:/testdir1#

In this example:

  • The first column represents the file type and permissions (-rw-r--r--).
  • The second column indicates the number of hard links to the file (1 in this case).
  • The third column shows the owner of the file (username).
  • The fourth column displays the group associated with the file (groupname).
  • The fifth column provides the file size (in bytes).
  • The last two columns show the modification date and time.

Here is the basic syntax of the chmod command:

chmod [options] mode file
  • options: Various options that modify the behavior of chmod.
  • mode: The permission mode you want to set, which can be specified using either symbolic notation or numeric notation.
  • file: The name of the file or directory for which you want to change permissions.

In symbolic notation, you can use letters and symbols to represent permissions:

  • u: User/Owner
  • g: Group
  • o: Others
  • a: All (equivalent to ugo)
  • +: Add permissions
  • -: Remove permissions
  • =: Set permissions

Permission symbols:

  • r: Read
  • w: Write
  • x: Execute

Examples of symbolic notation:

  • To give read and write permissions to the user on a file: chmod u+rw file.txt
  • To remove execute permissions from the group on a directory: chmod g-x directory_name
  • To set read-only permissions for all users on a file: chmod a=r file.txt

Numeric Notation:

In numeric notation, permissions are represented using a three-digit octal number. Each digit represents a group of permissions (user, group, and others), and each permission is assigned a value:

  • 4: Read permission
  • 2: Write permission
  • 1: Execute permission

To calculate the numeric mode, sum the values for the desired permissions:

  • Read (r): 4
  • Write (w): 2
  • Execute (x): 1

Examples of numeric notation:

  • To give read and write permissions to the user and no permissions to the group and others: chmod 600 file.txt
  • To give read and execute permissions to the user, read-only permissions to the group, and no permissions to others: chmod 541 script.sh

Common chmod Options:

  • -c: Display a message for each file processed.
  • -f: Suppress error messages.
  • -R or --recursive: Recursively change permissions for directories and their contents.
  • --reference=file: Copy permissions from another file to the specified file or directory.

Here are a few more examples of how to use chmod:

  • To make a script executable: chmod +x script.sh
  • To remove write permissions for everyone except the owner: chmod go-w file.txt
  • To recursively change permissions for all files and directories under a directory: chmod -R 755 directory_name

Remember that changing file permissions should be done carefully, especially when using the chmod command with elevated privileges, as incorrect permissions can affect the security and functionality of your system.

The chown command in Linux is used to change the ownership of files and directories. Ownership refers to the user and group associated with a file or directory. Changing ownership can be useful when you need to transfer control of a file or directory from one user or group to another.

The basic syntax of the chown command is as follows:

chown [OPTIONS] [OWNER][:GROUP] FILE
  • OPTIONS: Various options that modify the behavior of chown.
  • OWNER: The new owner of the file or directory.
  • GROUP: The new group associated with the file or directory (optional).
  • FILE: The name of the file or directory for which you want to change ownership.

Change Ownership of a File:

sudo chown new_owner: newfile.txt

Change Ownership of a Directory and Its Contents:

To change the ownership of a directory and all its contents (recursively), you can use the -R or --recursive option:

sudo chown -R new_owner: new_directory/

Change Ownership of Multiple Files:

sudo chown bob:users file1.txt file2.txt file3.txt

Preserve Timestamps with --preserve:

By default, chown updates the access and modification timestamps of files and directories. To preserve these timestamps, you can use the --preserve option:

sudo chown --preserve new_owner: file.txt

01.

Design

Aenean diam dolor, accumsan sed rutrum. Lorem ipsum dolor sit amet.

02.

Quality

Aenean diam dolor, accumsan sed rutrum. Lorem ipsum dolor sit amet.

03.

Innovation

Aenean diam dolor, accumsan sed rutrum. Lorem ipsum dolor sit amet.

04.

Execution

Aenean diam dolor, accumsan sed rutrum. Lorem ipsum dolor sit amet.