Linux commands working with file contents:
head, tail, cat, tac, more, less and strings, more file
attributes: hard links, symbolic links, fins, umask
and inodes The Linux file tree: the root directory, binary
directories, configuration directories, data
directories, Commands and arguments: $PATH,
echo, ls, env
5. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ Cat
✓ it does is copy standard input to standard output
✓ you can use cat to display a file on the screen
✓ Cat vikram.txt
✓ concatenate - concatenate files into a bigger file
✓ echo file1 >f1
✓ echo file2>f2
✓ echo file3 >f3
✓ cat f1 display
✓ cat f1 f2 f3 concatenate
✓ cat f1 f2 f3 >all all three files copied to all file
✓ cat all display all file
✓ use cat to create flat text files
✓ cat > vikram.txt
✓ cat can be used to copy files
✓ cat vikram.txt > pagat.txt
Commands with file contents
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 5
7. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ More and Less
✓ The more command is useful for displaying files that take up
more than one screen.
✓ More will allow you to see the contents of the file page by
page.
✓ Use the space bar to see the next page, or q to quit.
✓ Some people prefer the less command to more
✓ More vikram.txt example
✓ Strings
✓ strings command you can display readable ascii strings
found in (binary) files
✓ strings /bin/ls example
Commands with file contents
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 7
8. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ Inodes
✓ An inode is a data structure that contains metadata about a
file.
✓ name of the file, the creation date, its permissions, the owner
of the file, and more.
✓ ls –l /home/project42/
✓ drwxr-xr-x 4 root pro42 4.0K Mar 27 14:29 /home/project42/
✓ df -i command to see how many inodes are used and free on
mounted file systems.
✓ see the inode numbers with the ls -li command
Commands with more file attributes
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 8
9. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ hard links
✓ ln file2 hardlink_to_file2
✓ symbolic links
✓ ln -s file2 symlink_to_file2
✓ umask
✓ When creating a file or directory, a set of default permissions
are applied.
✓ These default permissions are determined by the umask.
✓ The umask specifies permissions that you do not want set on
by default.
✓ You can display the umask with the umask command.
✓ umask
Commands with more file attributes
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 9
10. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ Filesystem Hierarchy Standard
✓ http://www.pathname.com/fhs/
✓ man hier - Linux distributions - different
✓ the root directory
✓ Everything that exists on your Linux system can be found
below this root directory.
✓ ls /
✓ binary directories
✓ Binaries are files that contain compiled source code (or
machine code).
✓ Binaries can be executed on the computer.
✓ Sometimes binaries are called executables.
✓ The /bin directory contains binaries for use by all users
The Linux file tree
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 10
11. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ binary directories
✓ /sbin –system binaries
✓ /lib /bin and /sbin often use shared libraries located in /lib.
✓ /lib/modules/$kernel-version/
✓ configuration directories
✓ /boot directory contains all files needed to boot the computer
✓ ./boot/grub contains /boot/grub/grub.cfg - which
✓ defines the boot menu that is displayed before the kernel
starts
✓ ls /etc/*.conf All of the machine-specific configuration files
should be located in /etc - Editable Text Configuration
The Linux file tree
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 11
12. JAIN
–
DEEMED
TO
BE
UNIVERSITY
GLOBAL
CAMPUS:
45th
km
NH
-
209
Jakkasandra
Post,
Kanakapura
Rd,
Bengaluru,
Karnataka
562112
Department of CSE
✓ Data Directories
✓ Users can store personal or project data under /home.
✓ /root is the default location for personal data and profile of
the root user. If it does not exist by default, then some
administrators create it.
✓ use /srv for data that is served by your system
✓ The /media directory serves as a mount point for removable
media devices such as CDROM's, digital cameras, and
various usb-attached devices.
✓ The /mnt directory should be empty and should only be used
for temporary mount points
✓ Applications and users should use /tmp to store temporary
data when needed.
The Linux file tree
2/20/2023 Linux Internals by Dr. Vikram Neerugatti 12