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

learn more… | top users | synonyms (1)

15
votes
1answer
414 views

Make program first read from pipe, then from keyboard

Consider the interactive program interactive. I have to run this program fairly frequently, and each time I run it the first few commands are the same. Obviously, having to type those commands over ...
15
votes
4answers
7k views

How to Execute multiple command using nohup

I want to execute multiple command using nohup, And each command should execute after previous command, I used this command for example: nohup wget $url && wget $url2 > /dev/null ...
15
votes
1answer
6k views

What do double slashes mean in UNIX path? Is `cd dir/subdir//` valid? [duplicate]

Possible Duplicate: How linux handles multiple path separators (/home////username///file) Do cd dir/subdir/ and cd dir/subdir// mean the same in UNIX? Will the later work out? Else does ...
15
votes
2answers
6k views

Is it possible to save as sudo from nano after you've forgotten to run as sudo?

A lot of the time I edit a file with nano, try to save and get a permission error because I forgot to run it as sudo. Is there some quick way I can become sudo without having to re-open and re-edit ...
15
votes
1answer
2k views

copy (to X clipboard) shortcut in .tmux.conf

In order to copy text to X clipboard in tmux, what I currently do is: go selection mode with prefix[ start selection with space (using mode-keys vi btw) select the text and press enter copy tmux ...
14
votes
2answers
1k views

Accidently created a file called -X, how can I delete it? [duplicate]

Possible Duplicate: How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)? Like an idiot, I ran this command: tar -cf -X awstats-icon icon ...
14
votes
4answers
14k views

How do I make multiple directories at once in a directory?

I know with mkdir I can do mkdir A B C D E F to create each directory. How do I create directories A-Z or 1-100 with out typing in each letter or number?
14
votes
5answers
5k views

What is the difference between ls and l?

I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is ...
14
votes
7answers
3k views

Isn't less just more?

When I do more filename and less filename, it would seem that the resulting terminals are quite similar. I can navigate and search through my files identically (j, Space, /pattern, etc.). I find it ...
14
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
18k views

How to copy the partition layout of a whole disk using standard tools

I want to take a backup of the whole partition layout of a hard drive, including logical drives, so that I can restore that layout to another disk. I do not want to copy the contents of the ...
14
votes
2answers
2k views

How can I count the number of different characters in a file?

I would need a program, that outputs the number of the different characters in a file. Example: > stats testfile ' ': 207 'e': 186 'n': 102 Exists any tool, that do this?
14
votes
1answer
3k views

What are the differences between most, more and less?

I'm now using Arch Linux, and find a command most works like more and less. To understand the differences between them is a confusing problem. This Question has mentioned the differences between less ...
14
votes
2answers
992 views

Is it harmful to close a terminal window without properly exiting an application?

Using Ubuntu 12.04 LTS, my question is that if I started an application in a terminal window, then is there anything bad about just closing the terminal window without exiting the application properly ...
14
votes
1answer
306 views

Is there a way to search manpages for typical use scenario?

I have a relatively small brain, so there is a limit to what I can store up there. I have been using Linux semi-pro-amateur for a few years and still I am amazed at how little commands I know. Simple ...
13
votes
6answers
1k views

Can a Linux command have capital letter(s)?

Can a Linux command have capital letter(s)? I know it's supported but i want to be sure if it's a "problem" or considered "not a good thing"?
13
votes
3answers
8k views

How to stop a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to stop its process, then start it again. How can I stop it? I haven't close its shell window. ...
13
votes
4answers
3k views

Why do some commands 'hang' the terminal until they've finished?

Sometimes you run a program from the terminal, say, lxpanel†. The terminal won't drop you back to the prompt, it'll hang. You can press Ctrl+C to get back to the prompt, but that will kill ...
13
votes
3answers
3k views

How to kill a process with a single command?

I want to kill a process, after finding the id in a single step. I currently use these two commands: pidof <name> kill <#number_which_is_result_of_command> How can I write a single ...
13
votes
4answers
13k views

What's the best way to join files again after splitting them?

If I have a large file and need to split it into 100 megabyte chunks I will do split -b 100m myImage.iso That usually give me something like xaa xab xac xad And to get them back together I have ...
13
votes
7answers
6k views

diff within a line

I have some sql dumps that I am looking at the differences between. diff can obviously show me the difference between two lines, but I'm driving myself nuts trying to find which values in the long ...
13
votes
4answers
3k views

how to download a file using just bash and nothing else (no curl, wget, perl, etc.)

I have a minimal headless *nix which does not have any command line utilities for downloading files (e.g. no curl, wget, etc). I only have bash. How can I download a file? Ideally, I would like a ...
13
votes
3answers
7k views

Copy and paste a file/directory from command line

Instead of using the following command: cp {source file} {dest file} I want to be able to copy a file into the clipboard, and paste it somewhere else, in another directory. something like this: ...
13
votes
1answer
916 views

zsh Interpret/ignore commands beginning with '#' as comments

In bash, if I type a command beginning with a '#', bash ignores it as a comment. Ie, the following is ignored at the bash prompt: > # Hi there! Whereas in zsh: > # Hi there ! zsh: bad ...
13
votes
1answer
16k views

How to use command line to change volume?

I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux? Mute/ Unmute Volume up and volume down Note: Please note that I use a web USB ...
13
votes
6answers
1k views

Text only mode in Linux (No Gnome, KDE, Unity) to prolong battery life

If I want to disable my GUIs completely to save battery life, how would I proceed? I know that I can hit Ctrl + Alt + F3 and be on the command line, but the desktop manager would be in the background ...
13
votes
1answer
5k views

How do I find the window dimensions and position accurately?

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 ...
13
votes
2answers
1k views

Copying files from command line to clipboard

In a GUI file manager it is possible to select a few files, press Ctrl-C (which supposedly copies come info about the files to clipboard), then navigate to another folder and press Ctrl-V, which will ...
13
votes
2answers
3k views

How to invoke an Openoffice macro from the Linux command line

I have an OpenOfice macro that I want to use to process the contents of an OpenOffice file. I am able to do this by opening the file with OpenOffice and then running the macro. How do I invoke the ...
12
votes
5answers
4k views

Delete 100 lines from vi editor using single command

I am using Ubuntu and trying to delete all 100 lines from vi editor but I got interview question of doing this in one command.
12
votes
6answers
755 views

Subtract 1 from all file names (rename them) in a directory.

I have a directory which contains image files with names like image1.jpg image2.jpg image3.jpg ... Unfortunately, the image names must be zero based, so image1.jpg should be image0.jpg, ...
12
votes
10answers
1k views

Where do I master the most useful linux commands for programmers? [closed]

The power of combining xargs, cut, tail, grep, seq, amazes me. What resource should I look at for a tutorial on the most useful linux commands for programmers? I'm interested in just the ones ...
12
votes
2answers
629 views

What is a simple way to schedule a single event to happen at some time in the future?

There are often times that I want my computer to do a single task, but not right now. For example, I could have it notify me in 30 minutes that it is time to leave work. Or maybe I want it to run a ...
12
votes
1answer
1k views

What protocol/standard is used by terminals?

I was wondering how the "GUI" of a command line application is communicated over a network. Most of the time, it's quite simple (plain text / input) but sometimes it's more complex (aptitude). Is it ...
12
votes
4answers
6k views

How can I get a formatted date for a UNIX timestamp from the command line

I have a UNIX timestamp and I'd like to get a formatted date (like the output of date) corresponding to that timestamp. My attempts so far: $ date +%s 1282367908 $ date -d 1282367908 date: invalid ...
12
votes
3answers
4k views

Break a large file into smaller pieces

How do I break a large, +4GB file into smaller files of about 500MB each. And how do I re-assemble them again to get the original file?
12
votes
2answers
2k views

Is there a way to intercept interprocess communication in Unix/Linux?

For intercepting/analyzing network traffic, we have a utility called Wireshark. Do we have a similar utility for intercepting all the interprocess communication between any two processes in ...
12
votes
2answers
3k views

How to execute consecutive command from history?

Suppose I want to execute a sequence of four commands that I have executed before. If the first one is 432 in the command-history, then I could do: $ !432; !433; !434; !435 I'm curious, is there a ...
12
votes
4answers
1k views

Best method to collect a random sample from a collection of files

Suppose there is a directory holding 300 data files. I want to randomly select 200 of those files and move them into another directory. Is there a way to do that under Unix/Linux?
12
votes
1answer
5k 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 ...
12
votes
4answers
3k views

Converting colored output into html

There are tools providing coloured output: dwdiff -c File1 File2 # word level diff grep --color=always # we all know this guy ... The question is: How to convert their colored output of arbitrary ...
12
votes
2answers
2k views

Where do my ANSI escape codes go when I pipe to another process? Can I keep them?

I sometime want to pipe the color-coded output fror a process, eg. grep... but when I pipe it to another process, eg. sed, the color codes are lost... Is the some way to keep thes codes intact ? ...
12
votes
2answers
7k views

Filtering invalid utf8

I have a text file in an unknown or mixed encoding. I want to see the lines that contain a byte sequence that is not valid UTF-8 (by piping the text file into some program). Equivalently, I want to ...
12
votes
3answers
3k views

Command for forcing a pointer ungrab (captured mouse release)

Sometimes Firefox doesn't release the mouse after dragging, so I need to kill the application to force it to release its pointer grab. Is there any command to force an application to ungrab the ...
12
votes
3answers
3k views

Sunrise and other astronomical data from the command line

Is there a simple open-source, command-line program that can show the sunrise and sunset times at a given date and location, and perhaps moon and planet data as well? Browsing the Debian package ...
12
votes
2answers
252 views

`test` and `[` - different binaries, any difference?

I noticed while answering another question that test and [ are different binaries, but the [ manpage pulls up test's. Besides the requirement for an ending ], is there any difference? If not, why are ...
11
votes
5answers
13k 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
7answers
9k views

grep and tail -f?

Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
11
votes
3answers
2k views

How can I pipe output to another process, but retain the error state of the first process? [duplicate]

Possible Duplicate: Get exit code of process that's piped to another I am using the following command line (in a makefile) to pipe the verbose error messages from my compiler through a ...
11
votes
6answers
9k views

Deleting all files in a folder except files X, Y, and Z

I have a lot of files and folders in a specific folder and I want to delete all of them; however, I wanted to keep files X, Y, and Z. Is there a way I can do something like: rm * | but NOT grep | X ...