Basic Commands: Difference between revisions
No edit summary |
|||
| Line 66: | Line 66: | ||
Check disk usage information of a particular file system, type:<syntaxhighlight lang="shell"> | Check disk usage information of a particular file system, type:<syntaxhighlight lang="shell"> | ||
df /dev/sda5 | df /dev/sda5 | ||
</syntaxhighlight>'''Output''' | </syntaxhighlight>'''Output'''<syntaxhighlight lang="shell"> | ||
Filesystem 1K-blocks Used Available Use% Mounted on | |||
/dev/sda5 124595628 40714508 77505800 35% / | |||
Here, <code>/dev/sda5</code> has a total size of 40503552, the used size is 9132528, and the available size is 29283856. The file system has used 24% of the total allocated space and it is mounted on <code>/</code>. | </syntaxhighlight>Here, <code>/dev/sda5</code> has a total size of 40503552, the used size is 9132528, and the available size is 29283856. The file system has used 24% of the total allocated space and it is mounted on <code>/</code>. | ||
==du Command== | ==''du'' Command== | ||
Use the du (stands for disk usage) command to gain disk usage information of a particular file or directory on your Linux computer. By default, the du command displays disk usage information in the number of blocks used by a file. Use the -h option with this command to display output in a human-readable format. | Use the <code>du</code> ''(stands for disk usage)'' command to gain disk usage information of a particular file or directory on your [[Linux]] [[Komputer|computer]]. By default, the du command displays disk usage information in the number of blocks used by a file. Use the <code>-h</code> option with this command to display output in a human-readable format. | ||
Specify the file name or directory name to display its disk usage. | Specify the file name or directory name to display its disk usage.<syntaxhighlight lang="shell" line="1"> | ||
du -h /var/log/apache/access.log | |||
du -h /var/log | |||
</syntaxhighlight> | |||
==''cp'' Command== | |||
==cp Command== | |||
The <code>cp</code> command is used to copy files and directories from the source directory to another location. By default, it copies only the given file or directory, but you can use the <code>-r</code> option to copy a directory along with its subdirectories. | The <code>cp</code> command is used to copy files and directories from the source directory to another location. By default, it copies only the given file or directory, but you can use the <code>-r</code> option to copy a directory along with its subdirectories. | ||
The following command copy the file <code>users.txt</code> from the current working directory to the <code>Documents/records</code> directory. | The following command copy the file <code>users.txt</code> from the current working directory to the <code>Documents/records</code> directory.<syntaxhighlight lang="shell"> | ||
cp users.txt Documents/records/ | |||
</syntaxhighlight>To create a copy of the file <code>file2.txt</code> with the name <code>file2_backup.txt</code> in your current working directory.<syntaxhighlight lang="shell"> | |||
To create a copy of the file <code>file2.txt</code> with the name <code>file2_backup.txt</code> in your current working directory. | cp file2.txt file2_backup.txt | ||
</syntaxhighlight> | |||
==''mv'' Command== | |||
Use the <code>mv</code> ''(stands for move)'' command to move files or directories from the source to the destination directory. It can be used to rename a file/directory. | |||
To rename the employees.txt file to <code>users.txt</code>: | The following <code>mv</code> command moves the <code>users.txt</code> file to the <code>Documents/records</code> directory.<syntaxhighlight lang="shell"> | ||
mv users.txt Documents/records | |||
</syntaxhighlight>To rename the employees.txt file to <code>users.txt</code>:<syntaxhighlight lang="shell"> | |||
mv employees.txt users.txt | |||
</syntaxhighlight> | |||
==rm Command== | ==rm Command== | ||