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

learn more… | top users | synonyms (1)

37
votes
7answers
6k views

How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me ...
140
votes
5answers
7k views

What's the difference between $(stuff) and `stuff`?

There are two syntaxes for command substitution: with dollar-parentheses and with backticks. Running top -p $(pidof init) and top -p `pidof init` gives the same output. Are these two ways of doing the ...
54
votes
2answers
13k views

What does “--” (double-dash) mean?

I have seen -- used in the compgen command. For example: compgen -W "foo bar baz" -- b What is the meaning of the --.
60
votes
6answers
18k views

Keep SSH Sessions running after disconnection

I sometimes have long running processes that I want to kick off before going home, so I create a SSH session to the server to start the process, but then I want to close my laptop and go home and ...
93
votes
14answers
29k views

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5" What command can I use to get the numeric sum, e.g. 25 in this case. Also, what's the easiest way to do it just using bash for floating point, ...
53
votes
6answers
29k views

How can I close a terminal without killing the command running in it?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in ...
15
votes
8answers
4k views

Is there a robust command line tool for processing csv files?

I work with CSV files and sometimes need to quickly check the contents of a row or column from the command line. In many cases cut, head, tail, and friends will do the job; however, cut cannot easily ...
21
votes
4answers
8k views

Why do we use “./” to execute a file?

Why do we use ./filename to execute a file in linux? Why not just enter it like other commands gcc, ls etc...
18
votes
7answers
4k views

How to understand what's taking up space?

I'm looking for a linux alternative to WinDirStat. I would like to know what is taking up space on my hard drives. A program that works on console and doesn't require a UI is preferred .
5
votes
3answers
4k views

Storing output of command in shell variable

I have an operation using cut that I would like to assign result to a variable var4=echo ztemp.xml |cut -f1 -d '.' I get the error: ztemp.xml is not a command The value of var4 never gets ...
36
votes
5answers
12k views

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

Find filesystem of an unmounted partition from a script

I'm writing a custom automated install using AIF (Arch Installation Framework), and I need to find the filesystem on a partition given a partition. So far I have this: grok_partitions () { local ...
76
votes
12answers
23k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
139
votes
22answers
66k views

Repeat a Unix command every x seconds forever

There's a builtin Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat. For ...
31
votes
7answers
4k views

Linux tools to treat files as sets and perform set operations on them

Does anyone know of any linux tool specifically designed to treat files as sets and perform set operations on them? Like difference, intersection, etc?
18
votes
5answers
12k views

Split pages in pdf

I have a scanned pdf file which has scanned two pages on one virtual page (page in pdf file). The resolution is with good quality. The problem is I have to zoom when reading and drag from left to the ...
37
votes
9answers
12k views

how do you sort du output by size?

How do you sort du -sh /dir/* by size? I read one site that said use | sort -n but that's obviously not right. Here's an example that is wrong. [~]# du -sh /var/* | sort -n 0 /var/mail 1.2M ...
32
votes
3answers
8k views

What is the difference between Halt and Shutdown commands?

What is the difference between the halt and shutdown commands?
16
votes
8answers
665 views

How to tell what type of filesystem you're on?

Is there a command to tell what type of filesystem you're using?
21
votes
7answers
19k views

Do we have an undo in Linux?

I renamed a few files in one batch script. Is there a way to undo the changes without having to rename them back? Does Linux provide some native way of undoing?
16
votes
5answers
2k views

how to glob every hidden file except current and parent directory

I want to glob every hidden file and directory, but not the current (.) and parent directory (..). I am using bash. Observe current behaviour: $ ls -a . .. ...a ...aa ..a ..aa .a .aa .aaa ...
9
votes
2answers
3k views

When do su and sudo use different passwords?

I am able to run anything using sudo; my password is accepted. But whenever I try to do su from a shell, it fails with: su: incorrect password What can the problem be?
8
votes
1answer
807 views

How to run my own program without specifying its path

Let's suppose I have compiled something and I run it like so: $ /path/to/my/executable/mycmd Hello World What do I need to do to run it like $ mycmd Hello World from everywhere in my computer? ...
51
votes
8answers
2k views

Remember a half-typed command while I check something

I often find myself in the following position: I've started typing a long command at the bash prompt, but half-way through I find out I need to check something with another command. This is a problem ...
52
votes
10answers
10k views

How to grep a specific line _and_ the first line of a file?

Assuming a simple grep such as: $ psa aux | grep someApp 1000 11634 51.2 0.1 32824 9112 pts/1 SN+ 13:24 7:49 someApp This provides much information, but as the first line of the ps ...
27
votes
10answers
8k views

How do I reuse the last output from the command line?

This is a noob question, but I'd like to know how to reuse the last output from the console, ie: pv-3:method Xavier$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" ...
27
votes
7answers
2k views

Easy way to determine virtualization technology

I have command line access to a Linux machine which may or may not be virtualized. I want to determine what kind of virtualization technology it runs on, if any (VMWare, VirtualBox, KVM, OpenVZ, Xen, ...
10
votes
2answers
345 views

Order of redirections

I don't quite understand how the computer reads this command. cat file1 file2 1> file.txt 2>&1 If I understand, 2>&1 simply redirect Standard Error to Standard Output. By that ...
6
votes
4answers
2k views

Make cd automatically ls

I find that I often do the following: %> cd bla/bla %> ls I would like it that whenever I cd into a directory it automatically does an ls. I fiddled with my .bashrc for a while, but couldn't ...
5
votes
5answers
420 views

How can I reproduce commands run on one machine on another machine?

I would like to install some software on a linux-machine that I have run in VirtualBox. Then I would like to do the same thing on a linux-VPS. I think that I can save all commands that I run using ...
3
votes
2answers
338 views

`free`: output format

I use free to get the amount of free space on some of my servers. Its output is something like: $ free -m total used free shared buffers cached Mem: 374 ...
55
votes
21answers
7k views

Quick directory navigation in the terminal

I would like to frequently switch between directories that are in totally unrelated paths, for example /Project/Warnest/docs/ and ~/Dropbox/Projects/ds/test/. But I don't want to type cd ...
24
votes
4answers
1k views

Is there a one-liner that allows me to create a directory and move into it at the same time?

I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
27
votes
4answers
11k views

How can I send stdout to multiple commands?

There are some commands which filter or act on input, and then pass it along as output, I think usually to stdout - but some commands will just take the stdin and do whatever they do with it, and ...
22
votes
6answers
21k views

Where do files go when the rm command is issued?

Recently I accidentally did rm on a set of files and it got me thinking where exactly these files end up? That is to say, when working with a GUI, deleted files go to the Trash. What's the equivalent ...
19
votes
6answers
46k views

How do I make my pc speaker beep

Using bash, how can I make the pc speaker beep? Something like echo 'beepsound' > /dev/pcspkr would be nice.
20
votes
4answers
3k views

How do I send stdin to the clipboard?

Is there functionality in unix that allows for the following: echo "Some Text" | copy-to-clipboard
14
votes
3answers
13k 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 ...
16
votes
4answers
16k views

Understanding the exclamation mark (!) in bash

I used history | less to get the lines of previous commands and from the numbers on the left hand side I found the line I wanted repeated (eg. 22) and did !22 at the command prompt and it ...
9
votes
4answers
9k views

How can I make a program executable from everywhere

What should I do if I want to be able to run a given program regardless of my current directory? Should I create a symbolic link to the program in the /bin folder?
20
votes
2answers
3k views

How can I display syntax highlighting on a file?

Is there a variant of cat that outputs syntax-highlighted lines of code when used on a source file? An idea: maybe vi[m] or another editor can be asked to dump the syntax-highlighted contents of said ...
13
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 ...
9
votes
4answers
5k views

How do I merge two *.avi files into one

I have two *.avi files: sequence1.avi sequence2.avi How do I merge these two files using a command-line or GUI?
8
votes
3answers
7k views

How can I move files by type recursively from a directory and its sub-directories to another directory?

What would be a good way to move a file type from a directory and all of its sub-directories? Like "move all *.ogg in /thisdir recursively to /somedir". I tried a couple of things; my best effort was ...
17
votes
7answers
2k views

Command-line-friendly full-text indexing?

Is there such a thing as a full-text indexing engine, that can be queried from the command line and ideally wouldn't require using a gui at all ? I'm especially interested in indexing my ebooks and ...
9
votes
3answers
393 views

syntax_highlight <source_file> | lpr

Does anyone know of a simple way to produce the PostScript corresponding to a syntax-highlighted version of a source file that can be piped directly to a PostScript printer? As the wording of the ...
5
votes
4answers
4k views

All commands that should be used to connect to wifi in command line

I would like to switch from gnome to awesome and I would like to connect my wifi network in command line (instead of using gnome tools). So, I searched on the internet and found approximatively the ...
17
votes
7answers
8k views

Which mp3 tagging tool for Linux?

Which app would you recommend for Linux to tag MP3s? Under Windows I used to use tag&rename and liked it a lot; it works well under Wine, but I want something that runs natively
8
votes
1answer
2k views

Searching for a command line tagging tool for mp3 and ogg that supports pictures

I am searching a command-line tagging tool that supports ogg- and mp3-tagging and allows to add a picture to the tags. Currently I use lltag but that does not support pictures. dagger is the tool I ...
5
votes
1answer
2k views

Show a notification across all running X displays

Using the command line, I'd like show a notification on every running X display. ( and running console ) Something like: notify-send-all 'Warning' 'Nuclear launch in 5 minutes, please evacuate' Is ...