What is the unix command to see how much disk space there is and how much is remaining? - unix

I'm looking for the equivalent of right clicking on the drive in windows and seeing the disk space used and remaining info.

Look for the commands du (disk usage) and df (disk free)

Use the df command:
df -h

df -g .
Option g for Size in GBs Block and . for current working directory.

I love doing du -sh * | sort -nr | less to sort by the largest files first

If you want to see how much space each folder ocuppes:
du -sh *
s – summarize
h – human readable
* – list of folders

Note: The original question was answered already, but I would just like to expand on it with some extras that are relevant to the topic.
Your AIX installation would first be put into volume groups. This is done upon installation.
It will first create rootvg (as in root volume group). This is kinda like your actual hard drive mapped.
This would be equivalent to Disc Management in Windows. AIX wont use up all of that space for its file systems like we tend to do it in consumer Windows machines. Instead there will be a good bit of unallocated space.
To check how much space your rootvg would have you use the following command.
lsvg rootvg
That would stand for list volume group rootvg. This will give you information like the size of physical partitions (PP), Total PPs assigned to the volume group, Free PPs in the volume group, etc. Regardless, the output should be fairly comprehensive.
Next thing you may be interested in, is the file systems on the volume group. Each file system would have certain amount of space given within the volume group it belongs to.
To check what file systems you got on your volume group you use the following command.
lsvgfs rootvg
As in list volume group file systems for rootvg.
You can check how much space each file system has using the following command.
df
I personally like to refine it with flags like -m and -g (in megabytes and gigabytes respectively)
If you have free space available in your volume group, you can assign it to your file systems using the following command.
chfs -a size=+1G /home
As in change file system attribute size by adding 1 G where file system is /home. use man chfs for more instructions. This is a powerful tool. This example is for adjusting size, however you can do more with this command than that.
Sources:
http://www.ibm.com/developerworks/aix/library/au-rootvg/
+ My own experience working with AIX.

All these answers are superficially correct. However, the proper answer is
apropos disk # And pray your admin maintains the whatis database
because asking questions the answers of which lay at your fingertips in the manual wastes everybody's time.

su -sm ./*
You can see every file and folder size (-sm=Mb ; -sk=Kb) in the current directory like a list. This way runs in all Unix/Linux environment.

du -sm * => RULLLLLEZ

df -tk
for Disk Free size in 1024 byte blocks

Related

Rsync - regex for partial folder sync (folder starting with A to M)

I'm new to stackoverflow and hope i do everything right.
Can anybody help me? I have a raid volume that I would like backup/sync to two other drives. The two other drives are in sum the same size than the raid volume...
But how can I tell rsync to sync only the (root)folders starting with A to M to the first drive and N-Z to the second drive? (including all the subdirectorys, and files). My regex knowledge is nearly zero.
And no I dont want to make a raid volume out of the two drives.
Or is there an option in rsync to sync to two drives (if first is full, use second..)?
Thanks for your Ideas and help in advance.
Try using the following for the 1st
--exclude "/[N-Z]*/**"
and following for the 2nd
--exclude "/[A-M]*/**"
The man page would help you for creating the pattern.

how to get Disk Space used/free/total in Common Lisp

Seems that there is no standard functions to get used/free/total of Disk space in Common Lisp.
There is statvfs.h in Linux/Mac and GetDiskFreeSpaceEx function in Windows for C/C++.
Personally, it would call an executable to do that using a library.
Calling df -h with IOLib for example.
But this is not portable (particularly IOLib, but there are other libraries), and you have to parse the output of the commands.
That's one reason I love programs which have "machine readable" outputs: you can glue them up programmatically (à la shell script).
Another way would be to actually call these c function, using cffi or uffi (ffi standing for foreign function interface), but I haven't used neither, so I can't say much about it.
Oh, search on quickdocs.org, there is probably a library exactly for that, or maybe just to access the OS's API.
I wrote a new project cl-diskspace using statvfs to get disk total/free/available space in Common Lisp. Support Mac/Linux/Windows.
Update: 2015-07-11 now support Windows! Thanks to pjb, Guthur, Fare, |3b|
Install cl-diskspace with QuickLisp:
$ git clone https://github.com/muyinliu/cl-diskspace.git
$ cp -r cl-diskspace ~/quicklisp/local-projects/
Load cl-diskspace with QuickLisp:
(ql:quickload 'cl-diskspace)
Usage of cl-diskspace:
Get disk space information
(diskspace:disk-space "/")
Will get something like this:
127175917568
16509661184
16247517184
Means that the total space is 118.44G, free space is 15.38G and available space is 15.13G
Get disk total space
(diskspace:disk-total-space "/")
Will get something like this:
127175917568
Get disk free space
(diskspace:disk-free-space "/")
Will get something like this:
16509661184
Get disk available space
(diskspace:disk-available-space "/")
Will get something like this:
16247517184

Cannot compile. No space left on device error - Unix

I'm coding for class and when I try to compile I now get this error. Worked fine yesterday. IT does not work weekends so I'm out of luck until Monday unless someone can help. I'm fairly new to unix as I only really use it when coding.
cc scheduler.c
Close failure on scheduler.o : No space left on device
cc: acomp failed for scheduler.c
Delete some things on your disk. Use df (type 'man df' for usage) to see where the mount point is that you're compiling onto.
Check out the quota command. It'll show you how much space you get. You've probably just used up all the disk space you're allotted for you account. Go to your home directory:
> cd ~
and run:
> du -sh *
It will show how much space each of your directories takes up. Just remove some unused files.
If one directory takes up most of the space, you can cd into it and run du -sh * there too, to see the disk usage of its subdirectories. It's basically just a useful command for finding large files that you might not need anymore. For example, if you downloaded a really big program for a class project last year, but no longer need it, just rm it.

Using the diff command

So I am trying to compare a binary file I make when I compile with gcc to an sample executable that is provided. So I used the command diff and went like this
diff asgn2 sample-asgn2
Binary files asgn2 and sample-asgn2 differ
Is there any way to see how they differ? Instead of it just displaying that differ.
Do a hex dump of the two binaries using hexdump. Then you can compare the hex dump using your favorite diffing tool, like kdiff3, tkdiff, xxdiff, etc.
Why don't you try Vbindiff? It probably does what you want:
Visual Binary Diff (VBinDiff) displays files in hexadecimal and ASCII (or EBCDIC). It can also display two files at once, and highlight the differences between them. Unlike diff, it works well with large files (up to 4 GB).
Where to get Vbindiff depends on which operating system you are using. If Ubuntu or another Debian derivative, apt-get install vbindiff.
I'm using Linux,in my case,I need a -q option to just show what you got.
diff -q file1 file2
without -q option it will show which line is differ and display that line.
you may check with man diff to see the right option to use in your UNIX.
vbindiff only do byte-to-byte comparison. If there is just one byte addition/deletion, it will mark all subsequent bytes changed...
Another approach is to transform the binary files in text files so they can be compared with the text diff algorithm.
colorbindiff.pl is a simple and open-source perl script which uses this method and show a colored side-by-side comparison, like in a text diff. It highlights byte changes/additions/deletions. It's available on GitHub.

Compress EACH LINE of a file individually and independently of one another? (or preserve newlines)

I have a very large file (~10 GB) that can be compressed to < 1 GB using gzip. I'm interested in using sort FILE | uniq -c | sort to see how often a single line is repeated, however the 10 GB file is too large to sort and my computer runs out of memory.
Is there a way to compress the file while preserving newlines (or an entirely different method all together) that would reduce the file to a small enough size to sort, yet still leave the file in a condition that's sortable?
Or any other method of finding out / countin how many times each line is repetead inside a large file (a ~10 GB CSV-like file) ?
Thanks for any help!
Are you sure you're running out of the Memory (RAM?) with your sort?
My experience debugging sort problems leads me to believe that you have probably run out of diskspace for sort to create it temporary files. Also recall that diskspace used to sort is usually in /tmp or /var/tmp.
So check out your available disk space with :
df -g
(some systems don't support -g, try -m (megs) -k (kiloB) )
If you have an undersized /tmp partition, do you have another partition with 10-20GB free? If yes, then tell your sort to use that dir with
sort -T /alt/dir
Note that for sort version
sort (GNU coreutils) 5.97
The help says
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
I'm not sure if this means can combine a bunch of -T=/dr1/ -T=/dr2 ... to get to your 10GB*sortFactor space or not. My experience was that it only used the last dir in the list, so try to use 1 dir that is big enough.
Also, note that you can go to the whatever dir you are using for sort, and you'll see the acctivity of the temporary files used for sorting.
I hope this helps.
As you appear to be a new user here on S.O., allow me to welcome you and remind you of four things we do:
. 1) Read the FAQs
. 2) Please accept the answer that best solves your problem, if any, by pressing the checkmark sign. This gives the respondent with the best answer 15 points of reputation. It is not subtracted (as some people seem to think) from your reputation points ;-)
. 3) When you see good Q&A, vote them up by using the gray triangles, as the credibility of the system is based on the reputation that users gain by sharing their knowledge.
. 4) As you receive help, try to give it too, answering questions in your area of expertise
There are some possible solutions:
1 - use any text processing language (perl, awk) to extract each line and save the line number and a hash for that line, and then compare the hashes
2 - Can / Want to remove the duplicate lines, leaving just one occurence per file? Could use a script (command) like:
awk '!x[$0]++' oldfile > newfile
3 - Why not split the files but with some criteria? Supposing all your lines begin with letters:
- break your original_file in 20 smaller files: grep "^a*$" original_file > a_file
- sort each small file: a_file, b_file, and so on
- verify the duplicates, count them, do whatever you want.

Resources