Linux and Unix are managed through a series of text files. Linux administrators do not normally use graphical editors to manage these configuration files. Editors such as WordPerfect, OpenOffice.org Writer, Microsoft Word normally either save files in a binary format or add tags. Unless text files are preserved in their original format, without tags, changes that are made can render a Linux system unbootable.
In RHCE certification you have to perform several tasks on command line. In this article I would some basic commands to create / edit /delete files on Linux system.
How to create and read files on command line in RHEL Linux
Everything in Linux can be reduced to a file.
cat
The most basic command for reading and creating files is cat. The cat filename command scrolls the text within the filename file. It also works with multiple filenames; it concatenates the filenames that you might list as one continuous output to your screen. You can redirect the output to the filename of your choice.
To Create a file
Use ctrl+d to save file
To read the contain of file
To extend the contain of file use >> with cat command
While extending contents from cat command take care of > . User single > to create new file and >> to extend the contents. If you have used single > to extended the content if would overwrite the existing content of file without any warning.
How to create directories on command line in RHEL Linux
Directories are special types of files that serve as containers for other files.
mkdir
Basic command to create new directory.
To create directory tree use -p
How to delete files / directories on command line in RHEL Linux
To remove directory use rmdir command
To delete file use rm command
rmdir command would not delete a directory which contain data inside it
To delete a directory which contain data inside it use rm command with –rf option
No comments:
Post a Comment