To create a new file and add content to it, you can use the cat command with the output redirection operator (>).
[system]$ cat > samp.txt
The cat command is used to concatenate and display the content of files. When used with the output redirection operator (>), it creates a new file or overwrites an existing one with the content entered from the keyboard.
In the example, the user is prompted to enter the content for the file samp.txt. After pressing the Enter key, the content is saved to the file.
To display the contents of a file, you can use the cat command followed by the filename.
[system]$ cat samp.txt
The cat command, when used without redirection, displays the content of the specified file (samp.txt in this case) in the terminal.
To list the files and directories in the current working directory, use the ls command.
[system]$ ls
The ls command lists the files and directories in the current working directory.
In the example, several filenames and directories are listed.
To add content to the end of a file, use the cat command with the append operator (>>).
[system]$ cat >> samp.txt
The cat command with the append operator (>>) is used to add content to the end of the file samp.txt.
After executing the command, the user is prompted to enter additional content, which will be appended to the file when they press Ctrl+D.
To count the number of lines, words, and characters in a file, use the wc command.
[system]$ wc sam.txt
or
[system]$ wc -w sam.txt
The wc command is used to count the number of lines, words, and characters in a file.
The first command (wc sam.txt) displays the number of lines, words, and characters in the file sam.txt.
The second command (wc -w sam.txt) displays only the number of words in the file sam.txt.
To create an empty directory, use the mkdir command followed by the directory name.
[system]$ mkdir empty
The mkdir command is used to create a new directory with the name empty in the current working directory.
To remove an empty directory, use the rm command followed by the directory name.
[system]$ rm empty
The rm command is used to remove a file or directory. In this case, it is used to remove the empty directory named empty.
To view file permissions along with other details, use the ls -l command.
[system]$ ls -l
The ls -l command displays detailed information about the files and directories in the current working directory, including permissions, owner, group, size, modification date, and filename.
To view the absolute path of the current working directory, use the pwd command.
[system]$ pwd
The pwd command stands for "print working directory" and displays the absolute path of the current directory.
To create a new directory, use the mkdir command followed by the directory name.
[system]$ mkdir new_dir
The mkdir command creates a new directory with the name new_dir in the current working directory.
To print a message or a value to the terminal, use the echo command.
[system]$ echo "sat"
The echo command is used to print the string "sat" to the terminal.
To display the calendar for the current month, use the cal command.
[system]$ cal
The cal command displays the calendar for the current month, with the current day highlighted.
To display the current date and time, use the date command.
[system]$ date
The date command shows the current date and time in the format "Day Month Date Time Timezone Year."
To display the calendar for a specific year, use the cal command followed by the year.
[system]$ cal 2011
The cal 2011 command displays the calendar for the year 2011, showing each month with its corresponding days.
To view a list of users currently logged in, use the who command.
[system]$ who
The who command displays a list of users currently logged into the system, along with their login information.
To change the current working directory, use the cd command followed by the desired directory name.
[system]$ cd solai
The cd command is used to change the current working directory to solai.
To copy the contents of one file to another, use the cp command followed by the source and destination filenames.
[system]$ cp sam.txt sol.txt
The cp command is used to copy the content of the file sam.txt to the file sol.txt.
To move a file from one location to another, use the mv command followed by the source and destination filenames or directories.
[system]$ mv sol.txt sol/
The mv command moves the file sol.txt to the directory sol.
To rename a file, use the mv command followed by the current filename and the new filename.
[system]$ mv sol.txt sat.txt
The mv command renames the file sol.txt to sat.txt.
In summary, this blog post now contains detailed explanations for each Unix command, making it easier for readers to understand their functionalities and how to use them effectively.