Linux Basics: du Command Usage

Today we will discuss about how to find or summarize the disk usage on Unix/Linux systems using the du command. du stands forDisk Usage. In this handy tutorial, let us see how to use du command in real time.

Syntax

du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F

Usage

Let us see some practical examples. In this tutorial, I will be using /home/sk/unixmen/ directory to test du command. The /home/sk/unixmen directory contains the following content.

$ ls /home/sk/unixmen/ Akon - So Blue.mp4 panel.zip Senthilkumar_Resume.pdf sk.txt Ubuntu 13.10

1. Find Disk Usage with out any options

Entering the du command without any parameters will display following result.

$ du /home/sk/unixmen/

Sample output:

673800    /home/sk/unixmen/Ubuntu 13.10
679084    /home/sk/unixmen/

By default, du command displays the result in Kilobytes.

2. Display Disk Usage including all files and folders

As you see in the above result, If you execute du command without any parameters, it will display disk usage occupied by the directories only. So, If you want to find the disk usage of all files and directories, use -a flag.

$ du -a /home/sk/unixmen/

Sample output:

516    /home/sk/unixmen/panel.zip
4672    /home/sk/unixmen/Akon - So Blue.mp4
0    /home/sk/unixmen/sk.txt
673796    /home/sk/unixmen/Ubuntu 13.10/ubuntu-13.10-server-i386.iso
673800    /home/sk/unixmen/Ubuntu 13.10
92    /home/sk/unixmen/Senthilkumar_Resume.pdf
679084    /home/sk/unixmen/

3. Display Disk Usage in human readable format

As you see in the above outputs, the disk usage size is shown as some random numbers (679084) which is difficult to understand the exact size, atleaset for beginners. So let us display the disk usage size in human readable format such as in KB, MB, GB etc.

To calculate the disk usage in human readable format, use -h flag.

$ du -ah /home/sk/unixmen/

Sample Output:

516K    /home/sk/unixmen/panel.zip
4.6M    /home/sk/unixmen/Akon - So Blue.mp4
0    /home/sk/unixmen/sk.txt
659M    /home/sk/unixmen/Ubuntu 13.10/ubuntu-13.10-server-i386.iso
659M    /home/sk/unixmen/Ubuntu 13.10
92K    /home/sk/unixmen/Senthilkumar_Resume.pdf
664M    /home/sk/unixmen/

Now you can easily understand the disk usage sizes displayed in KB, MB, or GB format.

4. Display Disk Usage in MB or GB only

To display the disk usage of files and directories in Megabytes, or Gigabytes, use the parameter -B followed by M or G.

To display disk usage in Megabytes, enter the following command:

$ du -BM /home/sk/unixmen/

Sample output:

659M    /home/sk/unixmen/Ubuntu 13.10
664M    /home/sk/unixmen/

To display disk usage in Gigabytes, enter the following command:

$ du -BG /home/sk/unixmen/

Sample output:

1G    /home/sk/unixmen/Ubuntu 13.10
1G    /home/sk/unixmen/

5. Display Total Disk Usage

To display the total disk usage of files and directories, use -c option.

$ du -c /home/sk/unixmen/

Sample output:

673800    /home/sk/unixmen/Ubuntu 13.10
679084    /home/sk/unixmen/
679084    total

6. Display Total Disk Usage only

The previous command with -c option displays total size of the Disk Usage along with directories. If you want to skip all the results, and to display the total disk usage only, then use -s option.

$ du -s /home/sk/unixmen/

Sample output:

679084    /home/sk/unixmen/

To display the same result in human readable format, use -h option along with -s option.

$ du -sh /home/sk/unixmen/

Sample output:

664M    /home/sk/unixmen/

7. Display Disk Usage by excluding particular file types

Want to display the disk usage by excluding particular file types? For example, here we will summarize the disk usage result by excluding zip files.

$ du -h --exclude=*.zip* /home/sk/unixmen/

Sample output:

659M    /home/sk/unixmen/Ubuntu 13.10
663M    /home/sk/unixmen/

8. Display the Disk Usage by modification time

Do you want to display the disk usage by the modification time of files and directories? If yes, use –time option.

$ du -h --time /home/sk/unixmen/

Sample output:

659M    2014-02-25 17:56    /home/sk/unixmen/Ubuntu 13.10
664M    2014-02-25 17:56    /home/sk/unixmen/

I hope you get the enough details and usage of du command. For more advanced details, please refer the man pages.

$ man du

Cheers!

FocusWriter: A Multi-platform Simple And Distraction-free Writer

Mostly, I have a hardcore habit to document something interesting on the web, whether it may be a how-to document or tips & tricks related to Linux and/or any technology, and I will share them later to all the readers here in Unixmen. I have been looking for a tool which is going to ease and enhance the documenting work for a couple of days. After a bit searching on the web, I have found a simple and cool writer application called “FocusWriter”.

FocusWriter is a simple, distraction-free writing environment. It utilizes a hide-away interface that you access by moving your mouse to the edges of the screen, allowing the program to have a familiar look and feel to it while still getting out of the way, so that you can immerse yourself in your work. It’s available for Linux, Windows, and Mac OS X, and has been translated into many different languages.

Features

  • TXT, basic RTF, and basic ODT file support
  • Timers and alarms
  • Daily goals
  • Fully customizable themes
  • Typewriter sound effects (optional)
  • Auto-save (optional)
  • Live statistics (optional)
  • Spell-checking (optional)
  • Multi-document support
  • Sessions
  • Portable mode (optional)
  • Translated into over 20 languages

Installation

FocusWriter is available on all popular Linux distribution’s default repositories. So, you don’t have to add any extra repositories.

To install FocusWriter on Ubuntu/Debian based systems, enter the following command:

sudo apt-get install focuswriter

On Fedora based systems,

sudo yum install focuswriter

On SUSE:

zypper in focuswriter

On Mageia:

urpmi focuswriter

Launch FocusWriter

After installing FocusWriter, open it up either from Dash or Menu. This is how FocusWriter interface looked.

(Untitled 1)- — FocusWriter_001

Then, start writing without any distraction. After completing your document, hover the mouse pointer on the top the FocusWriter window, and you will see the Menu and Tool bars. From there, you can save or close or align the documents.

Cheers!

Source: FocusWriter website

Remarkable: A New MarkDown Editor For Linux

Remarkable is a new free fully featured Markdown editor for Linux distributions. It has features such as Live preview making markdown coding easier. It a lightweight editor and also has a simply User Interface (UI).

Below are the main features of Remarkable:

  • Live Preview
  • Github Markdown
  • Export to PDF and HTML
  • Custom CSS
  • Syntax Highlighting
  • Completely Customizable
  • Live Word Count
  • Keyboard Shortcuts

remarkable-full

Also checkout this YouTube video about Remarkable on Linux.

Installation

Remarkable is available to compile from source other sources for your various distros. Below are some distros and their instalations.

Ubuntu / Linux Mint:

Fedora:

Arch Linux (AUR):

sudo yaourt -S remarkable


How To Fix Xfce4-Panel Crashes In Manjaro Linux

What is the Cause?

XFCE Panel is crashing because: a running application is uses a font type in its title, since this type font (normally ttf and especiallyttf-droid) is not installed the panel crushes.

Solution

To fix this we need to install ttf-droid font. It is available in the main repo.

To install, Open Terminal and run the commands below:

sudo pacman -S ttf-droid
[sudo] pcwuyu 的密码:
正在解决依赖关系...
正在查找软件包冲突...

软件包 (1) ttf-droid-20121017-4

下载大小:    3.53 MiB
全部安装大小:  15.31 MiB
净更新大小:   0.00 MiB

:: 进行安装吗? [Y/n] y
:: 正在获取软件包......

After installation you should be able to access files and sites with Chinese and other fonts in their tile. For me, it was SM Player.

Install Sublime Text 3 (Build 3059) In Manjaro/Arch Linux

Sublime Text 3 is currently in beta. The latest build is 3059. We are going to install Sublime Text 3 build 3059 from AUR, from AUR.

Sublime_text_3_manjaro

Open terminal and run the command below, follow the Y/N questions to continue.

sudo yaourt -S sublime-text-dev

sublime_text_3_AUR

loading packages...
resolving dependencies...
looking for inter-conflicts...
Packages (1): sublime-text-dev-3.3059-1
Total Installed Size: 16.02 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring           [########################################] 100%
(1/1) checking package integrity         [########################################] 100%
(1/1) loading package files              [########################################] 100%
(1/1) checking for file conflicts        [########################################] 100%
(1/1) checking available disk space      [########################################] 100%
(1/1) installing sublime-text-dev        [########################################] 100%
==> sublime-text-dev install/upgrade note:
 ------------------------------------------------------------------------------
 To disable in-application reminders about new Sublime Text dev versions,
 add the following setting to your User Preferences file:
 "update_check": false
------------------------------------------------------------------

sublime_text_3

最新文章

最近回复

  • 测试: 评论测试内容
  • 袅残烟: [嘻嘻]万网域名也降价了
  • yxy: 以后,我会经常来逛的。
  • 袅残烟: LXDE可以搭配xf...
  • Fooleap: 从好几年前用 Lub...

分类

  • 默认分类 (26)
  • 运维 (53)
  • docker (1)
  • 动漫 (19)
  • 科普知识 (15)
  • 苍白边缘 (17)
  • 资源 (12)
  • Linux (58)
  • Arch Linux (19)
  • 计算机 (18)
  • 编程 (3)
  • Java (4)
  • python (0)
  • php (0)
  • 前端 (1)
  • 公告 (1)
  • 归档




      其它