RHCSA: How to manipulate files in RedHat

Reading Time: 2 minutes

Here is part 2 of the RHCSA learning sessions. This will focus on some of the core components to manipulate files.

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

You will learn how to:

Find Files

  • Find files
  • Read files
  • Manipulate test
  • Link files

Finding files is a key skill needed for any system admin.

There are a number of operator flags which 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 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 outputsall 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

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 in many ways, 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.

diff

Usually used to generate patch files, diff can display the differences between two or more files.

Linking Files

File name is pointer to inode

There are 2 types – 

  • hard link –  This is link between files that point to the same inode
  • soft link – is a pointer, acts like a redirect

You may also like...

1 Response

  1. 24/01/2021

    […] Part 2 – How to manipulate files in RedHat […]

Leave a Reply

Your email address will not be published. Required fields are marked *