The command-line is the interactive interface to your shell.
30
votes
2answers
6k 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 --.
26
votes
7answers
3k 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 ...
29
votes
4answers
13k 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 ...
13
votes
8answers
2k 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 ...
17
votes
6answers
2k 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 .
55
votes
12answers
12k 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 ...
100
votes
3answers
5k views
What's the difference between $(stuff) and `stuff`?
Running top -p $(pidof init) and top -p `pidof init` gives the same output. Are these two ways of doing the same thing, or are there differences?
18
votes
4answers
2k 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...
43
votes
6answers
10k 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 ...
6
votes
2answers
835 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 ...
75
votes
13answers
10k views
How to do integer & float calculations, in bash or other languages?
Using echo "20+5" literally produces 20+5
What command can I use to get the actual sum, e.g. 25 in this case.
Also, what's the easiest way to do it just using bash for floating point, e.g.
echo ...
14
votes
8answers
545 views
How to tell what type of filesystem you're on?
Is there a command to tell what type of filesystem you're using?
8
votes
2answers
2k 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
425 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?
...
21
votes
6answers
2k 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?
21
votes
5answers
6k 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.
17
votes
10answers
4k 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()"
...
14
votes
7answers
8k 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?
5
votes
4answers
840 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 ...
2
votes
2answers
212 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 ...
14
votes
5answers
8k 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 ...
24
votes
8answers
4k 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 ...
13
votes
5answers
11k 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 ...
8
votes
5answers
3k 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?
7
votes
3answers
304 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 ...
8
votes
1answer
208 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 ...
8
votes
1answer
1k 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
3answers
2k 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=ztemp.xml |cut -f1 -d '.'
I get the error:
ztemp.xml is not a command
The value of var4 never gets ...
3
votes
4answers
2k 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 ...
5
votes
1answer
1k 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 ...
4
votes
5answers
273 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
3answers
802 views
Show lines matching a pattern and the 4 lines before each
For example, from this file:
CREATE SYNONYM I801XS07 FOR I8010.I801XT07
*
ERROR at line 1:
ORA-00955: name is already used by an existing object
CREATE SYNONYM I801XS07 FOR ...
6
votes
2answers
449 views
Manipulating X key and pointer grabs on the command line
What command line tools exist to list and manage X server grabs? (That's grab as in key and pointer grabs, i.e. restricting the use of a particular key or mouse button to a particular application, or ...
86
votes
16answers
39k 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 ...
44
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 ...
44
votes
10answers
4k 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 ...
20
votes
4answers
970 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.
6
votes
10answers
810 views
Development environment for C
Looking for ideas on setting up a convenient and productive development environment for C development. I found C editing with Vim very helpful but I would like to get a wider sampling of suggestions.
22
votes
3answers
3k views
What is the difference between Halt and Shutdown commands?
What is the difference between the halt and shutdown commands?
10
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 ...
20
votes
3answers
3k views
How can I “relink” a lot of broken symlinks?
I have a directory tree which has a bunch of symbolic links to files under /home... however, I have moved /home to /mnt/home and need a way to "relink" all of the symlinks. Does such functionality ...
6
votes
4answers
5k 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?
15
votes
3answers
2k 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
15
votes
6answers
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 ...
14
votes
4answers
5k 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 ...
10
votes
4answers
13k 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 ...
8
votes
4answers
1k views
'mv' equivalent of drag and drop with replace?
In a GUI environment, a drag-and-drop with replace will replace files and entire directories (including contents) with whatever is being copied in. Is there a way to accomplish this same intuitive ...
12
votes
6answers
3k 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
9
votes
6answers
3k 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 ...
9
votes
3answers
1k 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 ...
