Most Popular

1500 questions
202
votes
5 answers

Is there any way to execute commands from history?

For example: [root@ip-10-0-7-125 ~]# history | grep free 594 free -m 634 free -m | xargs | awk '{print "free/total memory" $17 " / " $ 8}' 635 free -m 636 free -m | xargs | awk '{print "free/total memory" $9 " / " $ 10}' 736 df -h |…
The One
  • 4,862
202
votes
6 answers

Return only the portion of a line after a matching pattern

So pulling open a file with cat and then using grep to get matching lines only gets me so far when I am working with the particular log set that I am dealing with. It need a way to match lines to a pattern, but only to return the portion of the line…
MaQleod
  • 2,614
202
votes
5 answers

How to choose directory name during untarring

Say I have a file named ugly_name.tar, which when extracted, becomes ugly_name directory. What command can I use so that the resulting directory name is pretty_name instead?
tshepang
  • 65,642
201
votes
3 answers

What's the difference between a normal user and a system user?

Some documentation I'm going through has a boolean switch on whether or not a user is a 'system' user or a 'normal' user (defaulting to 'normal'). What is the difference between these two modes of user-ship? I don't need to learn what a user is or…
Sean Allred
  • 2,489
201
votes
5 answers

How do I add X days to date and get new date?

I have Linux ( RH 5.3) machine I need to add/calculate 10 days plus date so then I will get new date (expiration date)) for example # date Sun Sep 11 07:59:16 IST 2012 So I need to get NEW_expration_DATE = Sun Sep 21 07:59:16 IST…
yael
200
votes
4 answers

How to combine 2 -name conditions in find?

I would like to search for files that would not match 2 -name conditions. I can do it like so : find /media/d/ -type f -size +50M ! -name "*deb" ! -name "*vmdk" and this will yield proper result but can I join these 2 condition with OR somehow ?
Patryk
  • 14,096
200
votes
14 answers

How can I move files and view the progress (e.g. with a progress bar)?

When moving large directories using mv, is there a way to view the progress (%)? The cp command on gentoo had a -g switch that showed the progress.
letronje
  • 2,195
200
votes
14 answers

How to uncompress zlib data in UNIX?

I have created zlib-compressed data in Python, like this: import zlib s = '...' z = zlib.compress(s) with open('/tmp/data', 'w') as f: f.write(z) (or one-liner in shell: echo -n '...' | python2 -c 'import sys,zlib;…
mykhal
  • 3,231
200
votes
3 answers

ifconfig command not found

I've just installed CentOS7 as a virtual machine on my mac (osx10.9.3 + virtualbox) .Running ifconfig returns command not found. Also running sudo /sbin/ifconfig returns commmand not found. I am root. The output of echo $PATH is as below.…
RobSeg
  • 2,450
200
votes
3 answers

Easily unpack DEB, edit postinst, and repack DEB

I'm attempting to install Intel's OpenCL SDK but the DEB files are buggy conversions from RPM (see here for the curious). I need to edit the postinst script in the DEB they provide. How can I take an existing DEB, extract the contents (including…
John Jumper
  • 2,105
199
votes
6 answers

Generate File of a certain size?

I'd like to generate a file with the name example.file. I could use touch example.file but I want the file to be exactly 24MB in size. I already checked the manpage of touch, but there is no parameter like this. Is there an easy way to generate…
R_User
  • 2,093
  • 2
  • 13
  • 5
198
votes
5 answers

Is there a way to redirect nohup output to a log file other than nohup.out?

I frequently use the program nohup so that my processes are immune to hangups. So if I want to make the program program immune to hangups, I use the command nohup program & where & puts the process in the background. When starting, nohup gives me…
Andrew
  • 16,855
198
votes
4 answers

Where do executables look for shared objects at runtime?

I understand how to define include shared objects at linking/compile time. However, I still wonder how do executables look for the shared object (*.so libraries) at execution time. For instance, my app a.out calls functions defined in the lib.so…
rahmu
  • 20,023
198
votes
6 answers

How do I grep recursively through .gz files?

I am using a script to regularly download my gmail messages that compresses the raw .eml into .gz files. The script creates a folder for each day, and then compresses every message into its own file. I would like a way to search through this archive…
Kendor
  • 2,081
197
votes
6 answers

What are the pros/cons of Upstart and systemd?

It appears systemd is the hot new init system on the block, same as Upstart was a few years ago. What are the pros/cons for each? Also, how does each compare to other init systems?
tshepang
  • 65,642