Tag Info

Hot answers tagged

21

@Douglas Leeder, one more answer: Sort the human-readable output from du -h using another tool. Like Perl! du -h | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/; return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;' Split onto two lines to fit the display. You can use it this way or make it a one-liner, it'll work ...


13

As far as I can see you have three options: Alter du to sort before display. Alter sort to support human sizes for numerical sort. Post process the output from sort to change the basic output to human readable. You could also do du -k and live with sizes in KiB. For option 3 you could use the following script: #!/usr/bin/env python import sys import ...


11

I've had that problem as well and I'm currently using a workaround: du -scBM | sort -n This will not produce scaled values, but always produce the size in megabytes. That's less then perfect, but for me it's better than nothing (or displaying the size in bytes).


11

Found this posting elsewhere. Therefore, this shell script will do what you want without calling du on everything twice. It uses awk to convert the raw bytes to a human-readable format. Of course, the formatting is slightly different (everything is printed to one decimal place precision). #/bin/bash du -B1 | sort -nr |awk '{sum=$1; ...


9

find /my/dir -type f | while read filename ; do fuser -s $filename || echo $filename ; done This uses find just to generate a list of files. Then the while loop iterates over the list of results, for each result it runs fuser -s $filename which will exit with success if something is using the file. The || echo $filename part means "if fuser failed ...


8

Briefly... Linux is a kernel, FreeBSD is an Operating System. So you really can't compare them like you want. The major distributions of Linux each have various levels of compatibility and differences... but I'll try to hit the things you named at least: There are a couple different package managers (dpkg and rpm probably being the most popular) for Linux ...


7

This version uses awk to create extra columns for sort keys. It only calls du once. The output should look exactly like du. I've split it into multiple lines, but it can be recombined into a one-liner. du -h | awk '{printf "%s %08.2f\t%s\n", index("KMG", substr($1, length($1))), substr($1, 0, length($1)-1), $0}' | sort -r | cut -f2,3 ...


6

Hmm. glibc 2.5 is a dependency on pretty much everything in CentOS5. If you change it to glibc 2.7, your box will explode. Here's some discussion over in the CentOS forums: https://www.centos.org/modules/newbb/viewtopic.php?topic_id=28345&forum=41 https://www.centos.org/modules/newbb/viewtopic.php?viewmode=flat&topic_id=27133&forum=38


5

I haven't heard of it before now, but my knee-jerk reaction is "not another httpd". Apache is the Swiss-Army knife; Nginx is fast, IIS is the MS solution. There are others that fulfill a niche need in certain markets, but many suffer from being ill maintained, and have small followings. If it works for you, I'm all for it. But if you're starting from ...


5

Got another one: $ du -B1 | sort -nr | perl -MNumber::Bytes::Human=format_bytes -F'\t' -lane 'print format_bytes($F[0])."\t".$F[1]' I'm starting to like perl. You might have to do a $ cpan Number::Bytes::Human first. To all the perl hackers out there: Yes, I know that the sort part can also be done in perl. Probably the du part, too.


4

I got this from inside the help screen in nano by pressing ctrl-g: Ctrl F-Key Esc Key ^^ (F15) (M-A) Mark text at the cursor position M-^ (M-6) Copy the current line and store it in the cutbuffer ^U (F10) Uncut from the cutbuffer into the current line ^ = ctrl M = esc So you position your cursor at the ...


4

To discover which Linux flavor you're running, type the following commands: ls -al /etc/*release cat /etc/*release ls -la /etc/*version cat /etc/*version Depending on which Linux flavor you're running, you'll have a file that match one of above criteria, telling the Linux version. For example, RedHat has a /etc/redhat-release and Debian has a ...


4

"ps" displays the UID number if the user name is too long for the display, On Debian systems which include the "Debian-exim" user it is common to see this as the UID instead. This is probably what you're seeing. The presence of a '-' is a red herring here, and it happens everywhere that uses procps, not just Debian and Ubuntu: ...


3

The main claim to fame of UnxUtils is that it sits on top of MSVCRT.dll as opposed to glibc. This means that it is aware of native windows paths (i.e. you can use commands like ls c:). Some (particularly cygwin and SFU) map native DOS path names under a unix-like tree structure. Native DOS path support is useful if you want to execute unix commands from ...


2

if this started recently (last saturday...?) you could be affected by the leap second bug try running as root: date; date `date +"%m%d%H%M%C%y.%S"`; date; and see if this fixes your load problem


2

PowerNap is a project which provides this kind of functionality. Unfortunately the conditions are not easily extensible, and so if the conditions it provides do not suit your requirements you either need to hack the code or find something else.


2

Do not write a long-running program. Use cron to run a script every five minutes or so to create a file that is half an hour old (use the touch command) and then checks whether the various log files are newer than that reference file (using the test command). Perhaps in your system, sshd logs (via syslog) to the /var/log/messages file. This will not work ...


2

Tar Wars The Solaris tar format handles extended headers differently to GNU tar leading to a number of incompatibilities. star (Schily Tar) provides the best Linux support for the Solaris 7/8/9 format due to the work of Joerg Schilling over many years. Install star on your system and run: > star -xp artype=suntar f=Tarfilename.tar Other things to ...


2

on some systems, there is also lsb_release -a sherry [cpbills]$ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux testing (squeeze) Release: testing Codename: squeeze you can also do telnet localhost 25 to read the banner for your mail server. uname -a will print all the uname data, which ...


2

No. The GnuWin32 tools are (as the name implies) Win32 applications, i.e., they use the Win32 subsystem, not the POSIX subsystem. Of course, no matter what advice you may receive from strangers on the internet, you should test all your critical applications/services on a test system before making this change on any production systems. :-)


1

The two servers are the same model. They have the same modules loaded, but they are not using the same modules. lspci shows that the two servers of the same model use very different RAID controllers (I hate it when vendors do that: F*cking change the model number if it is not the same model!). On the server, where the disk works, you do not need to setup ...


1

--import is used to import keys, not to check a signature. The .asc file is usually a detached GPG signature. If you have files foo.tar.gz and foo.tar.gz.asc (or foo.tar.gz.sig), then you can verify the file foo.tar.gz with: gpg foo.tar.gz.asc In your case however, the filename does not match that pattern so you should specify the --verify option ...


1

Not sure where you got your "GNU Coreutils" from.... Years ago, I used UnxUtils. Reason? Just because I came across it first. And I liked that it, running on Windows, could handle that platforms path delimiter \ just fine... Later, I noticed that some if its tools didn't really work in all details/cli-switches like I needed them (and was used to from ...


1

The chown command requires root privileges. It will not run as any other user. You could restrict your command to only being able to change the ownership of files to the dummy user however, as Zoredache noted, this will still allow them to edit any file on the system. I don't know if sudo will work if /etc/sudoers is not owned by root but I'm certain that ...


1

The best way to do this is generally to use mutt instead: $ mutt -s "test subject" -a test.jpg user@example.com < test.txt mutt is available on most unix-like platforms these days and usually comes installed in the base OS. Your other option is to uuencode the file and send it through mail: $ uuencode test.jpg test.jpg | mail user@example.com ...


1

can try mail name@mailserver.com -s "Attached file" <<EOF Hi ~| uuencode $HOME/filename.txt filename.txt EOF atleast with gnus mailutils see http://mailutils.org/manual/html_section/mail.html


1

I believe the author is the same as the owner unless you're using GNU/Hurd, in which case the two can be different. I haven't used Hurd, so I can only guess at the intended use of a unique author field. I'm not aware of a --author flag in non-GNU versions of ls. It certainly doesn't exist in FreeBSD, which is the only other one I have easy access to right ...


1

My first knee-jerk reaction is that you should speak with the powers that be and make a plan to replace this machine. It may sound extreme, but when you inherit any environment you don't exhaustively understand you have two choices: Learn it inside and out and produce documentation, or replace it with a (well-documented) system you understand fully. Mail in ...



Only top voted, non community-wiki answers of a minimum length are eligible