The command-line is the interactive interface to your shell.

learn more… | top users | synonyms (1)

8
votes
3answers
677 views

Bash: Capture / Use last (or Nth) line in stdout

Query I use Bash. When I'm looking for files, often I'll do the following: find -name stackexchange.hs And often the results will look like: /youre/the/man/now/dog/stackexchange.hs ...
7
votes
2answers
18k views

How to display open file descriptors but not using lsof command

Hi I have read Here that lsof is not an accurate way of getting the number of File Descriptors that are currently open. He recommended to use this command instead cat /proc/sys/fs/file-nr While ...
7
votes
2answers
3k views

How do I merge two *.srt files

Please see this question. I have just merged two avi files cd1.avi and cd1.avi into movie.avi using: avimerge -o movie.avi -i cd{1,2}.avi Problem is that I had to subtitle files linked to the ...
7
votes
4answers
2k views

How to best encrypt and decrypt a directory via the command line or script?

I have a directory of text files under bazaar version control and keep a copy (a branch, actually) on each of my machines. I want to encrypt and unencrypt the directory via the command line. Ideally, ...
6
votes
4answers
2k views

using the mail command

How do I use the mail command to check email (and send email) from gmail. Does it support labels? I couldn't have figure out where to put the username and password. I tried to search for instruction ...
6
votes
2answers
5k views

How do I insert a space every four characters in a long line?

I've got a long line that I want to insert a space every 4 characters, on a single lone line of solid text to make it easier to read, what's the simplest way to do this? also I should be able to input ...
3
votes
2answers
10k views

No network connection in CentOS 6.3 Minimal under VMWare Player

I'm trying to replicate in VMWare Player the exact same conditions I have under my Dedicated Server for testing purposes. Now, the thing is that that when I try to install something, or ping ...
12
votes
1answer
6k views

ls taking long time in small directory

Running Ubuntu, I open a terminal and do sudo bash cd / ls | head -n 1000 And predictably about 20 directories are returned. However, if I do an ls, and don't pipe it into anything, the ls just ...
11
votes
3answers
15k views

How do I put a hat on 'e' (ê)?

Since I've migrated to linux a few years ago, one issue still remains. The ê character features a lot in my "moeder taal" (home language). In Windows making the character was easy, I simply had to ...
10
votes
4answers
14k views

How to boot Linux to command-line mode instead of GUI?

I am using 32-bit Red Hat Linux in my VM. I want to boot it to command-line mode, not to GUI mode. I know that from there I can switch to GUI mode using startx command. How do I switch back to ...
10
votes
2answers
1k views

Where has the trailing newline char gone from my command substitution?

The following code best describes the situation.  Why is the last line not outputting the trailing newline char?  Each line's output is shown in the comment.  I'm using GNU bash, version 4.1.5 ...
9
votes
4answers
3k views

Remove all `at` jobs

I know that to remove a scheduled at job I have to use atrm "numjob1 numjob2", but is there an easy way to do that for all the jobs?
8
votes
3answers
7k views

Safe way to pass password for >1 programs in bash

I'm writing a bash script, and need to ask user for his password and pass it to openssl. Whilst openssl can read the password itself, I need for two runs of the program and don't want to ask the user ...
7
votes
4answers
345 views

How to randomize the output from seq?

I know I can use seq to generate a random list of numbers 1, 2, 3, 4... I want to get those numbers into a random order like 3, 1, 4, 2... I know I can use shuf to shuffle the lines of a file. So I ...
7
votes
1answer
9k views

command to zip multiple directories into individual zip files

I have a single directory that contains dozens of directories inside of it. I'm new to command line and I'm struggling to come up with a command that will zip each sub-directory into a unique ...
7
votes
1answer
347 views

Is there a way to make perl -i not clobber symlinks?

A friend of mine points out that if you do: perl -pi.bak -e 's/foo/bar/' somefile when "somefile" is actually a symlink, perl does just what the docs say it will do: It does this by renaming ...
6
votes
4answers
492 views

pager program like less, able to repeat top N lines

Is there any way to make less program repeat first line (or first 2 lines) on every displayed page? Is there any other pager program which can do this? This would be a killer-app for database table ...
5
votes
0answers
66 views

How to write/edit/update the OsIndications efi variable from command line?

In the need to enter the UEFI firmware setup utility while using ultra fast boot (keyboard drivers are not loaded during POST), I wish to write to the "Os Indications" efi variable. My OS is Ubuntu ...
5
votes
3answers
1k views

Easy way to paste command line output to paste bin services?

Are there any command line tools on Linux that allow you to post output from commands or text files directly to a sharing service such as pastebin.com?
5
votes
5answers
916 views

resolve all ip addresses in command output using standard command line tools

I have several log files that contain a bunch of ip addresses. I would love to be able to pipe the data through a program that would match and resolve ip addresses. I.E. cat /var/log/somelogfile | ...
4
votes
4answers
7k views

Move all files with a certain extension from multiple subdirectories into one directory

Suppose I have a bunch of zip files in several directories: Fol1/Fol2 Fol3 Fol4/Fol5 And I want to move them all to a common base folder. How would I do this?
3
votes
7answers
475 views

Batch renaming of files [duplicate]

I have a directory full of images: DSCN4749.JPG DSCN4750.JPG DSCN4892.JPG ... And I would like a one-liner to rename them to (say). dscn4749.jpg dscn4750.jpg dscn4892.jpg ... How do I do this? ...
3
votes
2answers
400 views

I need help with a cronjob to watch for runaway processes and kill them

I have an interesting situation, I have a runaway ruby process - I know exactly how I trigger it. Point is, it got me thinking about runaway processes (CPU usage or memory usage). How would one ...
2
votes
1answer
196 views

cat file to multicast

I have a text file (test.txt) which represents captured network data. The actual protocol is text-based, with NULL line endings, so this isn't a problem. I need to run this test captured data ...
2
votes
1answer
250 views

Simpler processing of shell script options

I'm looking for way to process shell script arguments that is cleaner and more "self documenting" than getopt/getopts. It would need to provide... Full support of long options with or without a ...
21
votes
4answers
809 views

Are Linux utilities smart when running piped commands?

I was just running a few commands in a terminal and I started wondering, does Unix/Linux take shortcuts when running piped commands? For example, let's say I have a file with one million lines, the ...
15
votes
3answers
2k views

Why isn't there any shell command to create files?

Attention please: I am not asking how to make a file from the command line! I have been using touch for making files for years without paying attention that its main purpose is something else. If ...
14
votes
3answers
5k views

How do I find the window dimensions and position accurately including decorations?

I've been trying to figure out the size of a window for use in a small script. My current technique is using wmctrl -lG to find out the dimensions. However, the problem is this: The x and y figures ...
11
votes
5answers
15k views

Linux ls to show only filename date and size

How can I use ls in linux to get a listing of filenames date and size only. I don't need to see the other info such as owner or permission. Is this possible?
11
votes
2answers
2k views

IP to Country console command

Is there a console command that takes an IP address as an input and shows its geographical information like city, country, ISP, etc.?
10
votes
5answers
3k views

How to soft kill gui applications via terminal?

Is there a way to close a GUI application in friendly "please quit yourself now" way, without graphical access to the applications window? For example, if Gnome/X display crashes to black, I'd like ...
9
votes
11answers
8k views

How can I “cat” a file and remove commented lines?

I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ; For example, if the file contained this: ; - Show all errors, except for notices ; ...
8
votes
5answers
478 views

What's the best way to take a segment out of a text file?

What's a good way of extracting say, lines 20 -45 out of a huge text file. Non-interactively of course!
7
votes
5answers
1k views

Read and confirm shell script before piping from curl to sh (curl -s [url] | sh)

Whenever I have to execute a shell script from the web curl -s [url] | sh, I first open url in my web browser to make sure the script isn't malicious and is safe to run. I remember seeing a command ...
7
votes
2answers
2k views

Directory “diff”?

I have two directories which are different versions of the same software package. I'd like to list all the files/directories that have changed between the two then copy those differences to a new ...
6
votes
3answers
6k views

How to bring up a wi-fi interface from a command line?

I can't figure out how to properly bring up the wi-fi card on my laptop. When I turn it on and issue $ sudo iwconfig wlan0 txpower auto $ sudo iwlist wlan0 scan wlan0 Interface doesn't support ...
6
votes
1answer
1k views

How to mount a Truecrypt container with a timeout from the command line?

I'm mounting a truecrypt container via the command line (i.e. truecrypt file dir). Is there any way to have truecrypt automatically unmount the container after a given amount of inactivity in dir?
6
votes
3answers
2k views

How can I print good looking code

Similar to using markdown on Stack Overflow to create monospace output, how can I do that for my programs. I tried lp filename.txt and was pleasantly please to find that it was able to use the local ...
5
votes
2answers
981 views

A command line utility to visualize how fast a file is growing?

I want to grok how fast a particular file is growing. I could do watch ls -l file And deduce this information from the rate of change. Is there something similar that would directly output the ...
5
votes
2answers
77 views

Handling an option-like filename in the shell [duplicate]

Possible Duplicate: How do I delete a file whose name begins with "--"? Due to mismatched switches when I was trying to run a command, I have a log file named -w in a directory. I ...
4
votes
1answer
314 views

Executing a remote command on SSH connection, before login

I am trying to find a way to execute a specific command when connecting to a server via SSH. By this I mean, the command will execute unconditionally on opening a connection, so this would preferably ...
4
votes
1answer
430 views

Is there a command such as xwininfo, xdpyinfo, xprop, or xlsclient that will tell me what font an X client window is using?

I'm trying to find a command that will report what font a given X window is configured to use. Does such a command exist? Looking through these tools I did not see an option that would give me this: ...
4
votes
1answer
72 views

How can I get information about my virtual desktops via the command line?

I'm curious how I can get information such as the dimensions of my desktop, which desktop is currently active, and what labels (if any) are set for my desktop enviornment (DE).
4
votes
1answer
73 views

Computing the visible area of a partly hidden window

I have to (scriptly) take screenshots of windows, some of which may be partially or fully hidden by other windows. Of course, in such a case the screenshot is useless, and I'd rather print a warning. ...
4
votes
2answers
151 views

Is it possible to restrict certain commands from being run in a directory?

I have two directories: src and projects. I would like to prevent myself from running git ... unless I am specifically inside src or projects. Is this possible?
4
votes
3answers
264 views

Commandline global proxy program?

I'm living in China, and lots of web service is not available or stable here like Github/Bitbucket/Imgur, When I'm using wget, git or some other commandline tools, I need using a proxy. Is there any ...
4
votes
2answers
1k views

Is there any command-line, generic HTTP proxy (like Squid)?

I can easily use Netcat (or, Socat) to capture traffic between my browser and a specific host:port. But for Linux, does there exist any command-line counterpart of a Squid-like HTTP proxy that I can ...
4
votes
2answers
2k views

pdf viewer for command line only

Is it possible to view pdf documents without having gdm (or similar) running? Rationale: I'm working on a remote server (assume no X forwarding) processing some data, creating some plots (assume pdf ...
4
votes
4answers
423 views

ls command operating differently depending on recipient

How does commands like ls know what its stdout is? It seems ls is operating different depending on what the target stdout is. For example if I do: ls /home/matt/tmp the result is: a.txt b.txt ...
4
votes
2answers
1k views

How to prevent my screens from dimming (going black) from the command line

In KDE, there was a system setting where you could specifically set the monitors to never go black. Now I've switched to dwm and (it might not be related) my screens dim after about 10 minutes. How ...