How to manipulate files in RedHat
In the ever-evolving world of Linux, RedHat stands out as one of the most prominent and trusted distributions. At its core lies the ability to effectively manage and manipulate files, a foundational skill every system administrator or enthusiast should master. File manipulation encompasses the basics of creating, reading, and deleting files and delves deeper into advanced tasks like searching, linking, and text processing. As you embark on this journey through RedHat’s file system, you’ll discover tools and techniques that have been refined over decades, designed to make your work efficient and powerful. Whether you’re a seasoned pro looking to refresh your knowledge or a beginner eager to dive into the Linux universe, this guide on manipulating files in RedHat is your indispensable companion.
You will learn how to:
Find Files
- Find files
- Read files
- Manipulate test
- Link files
Finding files is a crucial skill needed for any system admin.
Several operator flags are useful for the find command.
–type
• f = regular file
find . -type f –name httpd.conf
• d = directory
find . –type d –name html
• l = symbolic link
find . –type l –name redhat-release
–user
• File is owned by the user (username or UID)
Find top 5 files.
find -type f -exec du -Sh {} + | sort -rh | head -n 5
Reading Files
• cat
This reads the file and outputs all of it to stdout.
• less and more
“Also known as”pagers” these commands will output the contents of a file to the screen, but allow you to navigate through the file as well”Also known as “pagers” these commands will output the contents of a file to the screen, but allow you to navigate through the file as well
• head and tail
These commands let you look at the lines starting at the top or bottom of the file, respectively.
Text Manipulation
• sort
• wc
This can be used to sort input alphabetically, numerically, or with different fields as the sort key. Sorting is also available in reverse.
“Short for”“word count,” this utility can count the number of lines, words, characters, bytes, and the length of the longest line in the file.”Short for “word count,” this utility can count the number of lines, words, characters, bytes, and the length of the longest line in the file.
• diff
Usually used to generate patch files, diff can display the differences between two or more files.
Linking Files
The file name is a pointer to the inode
There are two types –
- hard link – This is a link between files that point to the same inode
- soft link – is a pointer, acts like a redirect
RHCSA MiniSeries
Part 1 – How to use Grep and Regular Expressions (RegEx)
Part 2 – How to manipulate files in RedHat
Part 3 – Red Hat Permissions
Part 4 – How to change the root password on Red Hat
Part 5 – How to use Red Hat as a virtual machine host
Part 6 – How to configure local storage
Part 7 – how to manage users and groups in Red Hat Linux
Part 8 – how to configure NTP Network Time Protocol in Red Hat
8 Responses
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]
[…] Part 2 – How to manipulate files in RedHat […]