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

learn more… | top users | synonyms (1)

16
votes
3answers
782 views

Copy image from command-line to clipboard

Is there a way in a bash to copy a picture to the clipboard? For example if there is a picture mypic.png I want to have a command like clipcopy mypic.png such that I can go for example to inkscape ...
15
votes
4answers
15k 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?
15
votes
6answers
4k views

How to display numbers in reverse order using seq(1)?

I have iterate over numbers in various order. I am able to display them in increasing order, even with steps like: $ seq --separator="," 1 10 1,2,3,4,5,6,7,8,9,10 $ seq --separator="," 1 2 10 ...
15
votes
2answers
1k views

Create a test file with lots of zero bytes

I know how to create an empty file: touch /var/tmp/nullbytes but how can I create a 1MB file that only contains nullbytes on the commandline with bash?
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 ...
15
votes
3answers
19k 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 ...
15
votes
5answers
33k views

Is there a way to see details of all the threads that a process has in Linux?

For Windows, I think Process Explorer shows you all the threads under a process. Is there a similar command line utility for Linux that can show me details about all the threads a particular process ...
15
votes
10answers
10k views

What's a good example of piping commands together?

If you were helping someone to learn the concept of pipes on the command line what example would you use? The example that actually came up was as follows: cat whatever.txt | less I feel like ...
15
votes
1answer
427 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
2answers
1k views

Coloring different sources for tail

I'm watching different logs by tail -q -f /var/log/syslog -f /var/log/fail2ban.log -f /var/log/nginx/error.log How can I have the output of each log colored differently?
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
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
5answers
6k 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
3answers
12k 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. ...
14
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 ...
14
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 ...
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
308 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
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 ...
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
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 ...
13
votes
4answers
14k 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
7k 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
3answers
8k 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
962 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
6answers
2k 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
17k 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
2answers
8k 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 ...
13
votes
1answer
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 ...
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
6answers
6k views

How can I display the contents of a text file on the command line?

I would like to display the contents of a text file on the command line. The file only contains 5-6 characters. Is there an easy way to do this?
12
votes
5answers
5k 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
794 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
640 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
3answers
7k views

How to cause kernel panic with a single command?

Is it possible to cause a kernel panic with a single command line? What would be the most straightforward such command for a sudoing user and what would it be for a regular user, if any? Scenarios ...
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
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 ...
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
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
4k 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
254 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
14k 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?