Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.

learn more… | top users | synonyms

9
votes
1answer
935 views

Is there a way to sort my windows within a screen session?

I use screen and have ssh sessions open to a number of different machines from within my screen session. I'd like to keep them in order, for obvious reasons. Often I'll have to connect to a new ...
8
votes
3answers
3k views

Stop cron from emailing me

How can I stop cron from emailing me the results of jobs I schedule?
8
votes
4answers
1k views

How long is long for the Unix 'file' command?

When you pass a text file to the Unix file command, it might tell you something like: input.txt: UTF-8 Unicode English text, with very long lines Can somebody tell me the minimum number of ...
8
votes
6answers
6k views

unix - split a huge .gz file by line

I'm sure someone has had the below need, what is a quick way of splitting a huge .gz file by line? The underlying text file has 120million rows. I don't have enough disk space to gunzip the entire ...
8
votes
2answers
14k views

downloading file using scp command

I have a centos server lets say with ip: 1.2.3.4. I want to download a file from 1.2.3.4 at path /root/pc/filename.rar to my localhost host (current pc). What command I need to download that file? I ...
8
votes
5answers
4k views

awk, mawk, nawk, gawk… WHAT?

I've just started learning awk and I'm a little confused about all those versions around. Is there any "version" which is found on all Unix-like systems? Like, you know, plain vi? Does the standard ...
8
votes
2answers
872 views

In Unix “less”, can I jump to the next line that does NOT contain X?

In the Unix less tool, is it possible to jump to the next line that does not contain a certain expression? I sometimes have to look through files that contain thousands of similar adjacent lines ...
8
votes
6answers
5k views

Custom vim highlighting

I am editing some xml right now and I have been leaving myself some comments of things to come back to. Like this <!-- Question: bla bla --> I am editing with vim right now and I would like ...
8
votes
1answer
5k views

Aligning columns in output from a UNIX command

I used to know of a command -- an actual command mind you, not sed/awk magic -- that formatted its input to be aligned in columns. For example, if you ran: % echo -e "aaaaa bbbbbbb\ncc ddd" aaaaa ...
8
votes
4answers
14k views

How to call bash functions

Maybe I am looking at this the wrong way.. But here I what I am trying to do. Do most of my work with Java but just switched to a unix (bash) environment. I am doing this: [~/Desktop/bashPlay]% ...
8
votes
1answer
8k views

What's a good way to install “build essentials” (all common useful commands) on a blank EC2 Linux server?

I want to get some "build essentials" (like gcc, make, etc.) on an empty micro Linux box. Seems inefficient to spend my time trying to try installing one thing, then realize I need gcc, then realize ...
8
votes
5answers
13k views

sudo chmod -R 777 /

sudo chmod -R 777 / I did this. It was a mistake. Is there any way to undo it? Basically it's messed up more things than I can list. I don't have time-machine enabled on my mac.
8
votes
5answers
2k views

When would creating a hard link be useful?

There are basically two main limitations with hard links: Hard links normally require that the link and the file reside in the same file system. Only the superuser can create a hard link to a ...
8
votes
3answers
9k views

Unix - delete files and folders excluding PATTERN

Recently I was faced with the task of deleting all the files/folders in a directory excluding those matching a specific pattern. So I cooked up a single-line unix command to do the work. Must it be ...
8
votes
3answers
6k views

How do I set up SSH so I don't have to type a password, and without using a public key?

I know there are dozens of questions here about how to connect to an SSH server without typing your password every time, and the answer is always "use a public key." Well, I find myself in the rare ...
8
votes
3answers
15k views

Can files deleted with rm -rf be recovered?

When I delete folders or files in through osx terminal using the rm -rf, where do they go? I heard that some say they are deleted directly, but some also say it only "remove the link to the file ...
8
votes
2answers
13k views

groupadd/useradd not found on Mac OSX

Does anyone know how to add unix groupadd command on Mac OSX 10.5? I'm trying to do man on groupadd and useradd commands but it doesn't seem to exist.
8
votes
3answers
3k views

How can I create a cron job that runs a task every three weeks?

I have a task that needs to be performed on my project schedule (3 weeks). I'm able to set up cron to do this every week, or (for example) on the 3rd week of every month - but can't find a way to do ...
8
votes
4answers
6k views

Unix command-Line CSV viewer

Is there a convenient command-line csv viewer, possibly a unix tool or a mod of some tools (e.g. vim or python)? I find it easy to simply edit CSV files by writing it manually (since all you need to ...
8
votes
2answers
4k views

Run Script on File Change on Mac OS X

Anyone know about a program for Mac OS that you can pass the name to an executable and a file to watch, so that it then runs the executable everytime the file being watched changed? I have something ...
8
votes
1answer
1k views

STDOUT of a disowned program

As followup of this question, I would like to know where the STDOUT and STDERR of a program on which I've run disown -h is redirected to.
8
votes
1answer
6k views

sudo chown fails with operation not permitted

I have found similar questions here, but the answers provided to those questions do not resolve my problem. If I do: sudo chown <username> main.m I get an operation not permitted error. ...
8
votes
3answers
17k views

How to find which files and folders were deleted recently in Linux?

I am having one particular folder (/home/sam/officedocuments) which is having hundreds of folders and files. I think I deleted some files and folders by mistake but I'm not sure. How to find which ...
8
votes
2answers
198 views

Maintain permissions bits when writing new file with VIM

In Vim, when I write a copy of the current buffer to a new file using :w [filename], it appears that Vim uses the default (i.e. set by umask or whatever) file permissions for the new file. If the ...
7
votes
6answers
4k views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
7
votes
4answers
5k views

Windows PowerShell equivalent to Unix/Linux `pwd`?

In follow-up to the cmd.exe question, what is the PowerShell equivalent to echo %cd%, or Linux/Unix pwd?
7
votes
8answers
3k views

Ending a process in unix instead of interrupting it

At the unix command line if i press Ctrl-C,that does not end a process but rather interrupts it and i return to the shell prompt. So,i have the following two questions: 1.Is there a way i can see the ...
7
votes
3answers
6k views

I just got a Mac! How do I do “end” , “home”, “page up” and “page down” in my terminal/VIM editor?

I write a lot of python in my VIM, on the terminal. What do I do?
7
votes
12answers
2k views

Is there a Unix-y tool for taking notes on the command line?

I'm looking for something really quick and simple: type note <title>, start writing, and exit. Ideally with a simple list to jump to a specific note. Is there such a thing?
7
votes
4answers
12k views

count lines in a compressed file

if i have a .gz file on unix which has certain number of lines. How could i count the lines on unix without uncompressing it.
7
votes
2answers
1k views

What prevents rm /dev/null?

What is the mechanism by which rm /dev/null is prevented? Specifically on FreeBSD, but I'm just as interested in all other Unix based systems.
7
votes
4answers
5k views

Keep a program running after closing a console, after the program has started [duplicate]

Possible Duplicate: How do I detach a process from Terminal, entirely? I've a program running in a Unix console on a remote Unix computer. I (stupidly) didn't run it using nohup &, and ...
7
votes
4answers
10k views

How to limit output of ls to only show 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, permission.
7
votes
3answers
30k views

Howto unzip “.xz” file with 7z and lzma

I tried to uncompressed a "*.xz" file with both 7z and lzma. But they gave me such message: $ 7z x myfile.fq.xz 7-Zip 4.57 Copyright (c) 1999-2007 Igor Pavlov 2007-12-06 p7zip Version 4.57 ...
7
votes
4answers
460 views

Documenting Unix commands on the command line

I would like to append both the last command and the output of the last command to a text file for the purpose of a tutorial. For example: After I do an ls in my home directory I see this on the ...
7
votes
5answers
7k views

How can I sort all files by size in a directory?

How can I display the files in a unix directory sorted by their human readable size, going from largest to smallest? I tried du -h | sort -V -k 1 but it does not seem to work.
7
votes
3answers
15k views

How to find the largest file in a directory? [duplicate]

Possible Duplicate: Unix command to list all directories larger than 10mb How to find the largest file in a directory?
7
votes
3answers
73k views

How to change file permissions for a directory in one command

How can I change all the file permissions of a directory in one command in Unix?
7
votes
5answers
18k views

how to use netstat to show what process is listening on a port

I'm on an OS X mountain lion laptop and have a couple of Vagrant boxes on it. I'm trying to figure out which process is listening on port 8080. My variations produce like a hundred lines but none ...
7
votes
4answers
4k views

Sorting numerically in a comma-delimited file with Unix

I've got a comma-separated file that looks like this: 100,00869184 6492,8361 1234,31 200,04071 I want to use sort to sort this file numerically by the first column only. Desired Result: ...
7
votes
3answers
3k views

Transforming CSV file using sed

In order to be able to import some data into a certain tool, I have to transform a CSV file from this format "data","data","data data","data","123" into this format data;data;data data;data;123 ...
7
votes
5answers
8k views

How to get the actual directory size (out of du)?

How do I get the actual directory size, using UNIX/Linux standard tools? Alternative question: How do I get du to show me the actual directory size? Since people seem to have different definitions ...
7
votes
2answers
7k views

Faster alternatives to “find” and “locate”?

I will like to use "find" and locate" to search for source files in my project, but they take a long time to run. Are there faster alternatives to these programs I don't know about, or ways to speed ...
7
votes
4answers
12k views

Unix 'grep' for a string within all gzip files in all subdirectories

How do I grep for a string recursively through all .gz files in all directories and subdirectories?
7
votes
3answers
1k views

List file range with UNIX wildcards

Say for example I have the following files in my working directory: mjk0001.fits, mjk0002.fits, ... numerically increasing all the way to mjk9999.fits. Is there a way to use UNIX wildcards to list or ...
7
votes
1answer
2k views

Does rm -r follow symbolic links?

If I have symbolic links in some subtree of my directories and decide to recursively removed a driectory and its contents, will that remove items symbolically linked in the tree?
7
votes
1answer
2k views

ZSH tab completion of git commands is very slow. How can I turn it off?

If I type: rm <TAB> I'll see possible completions almost instantly. However, if I type: git rm <TAB> It'll hang for several seconds if it's in a git repo, or fail to show any ...
7
votes
4answers
9k views

How do I log all UNIX shell commands submitted by all users?

Is there an elegant way to log every command submitted in all shells on a machine? This is in the context of an infrequently-used Ubuntu server, of which I am the only human user. (There are several ...
7
votes
2answers
2k views

What exactly does the dd command do?

A few days ago I was delighted to find out that it's not all that difficult to write an iso image to a USB without the help of a third-party program explicitly designed to do so. But the command (or ...
7
votes
4answers
22k views

How do I compare two files with a shell script?

Given two files, I want to write a shell script that reads each line from file1 and checks if it is there in file2. If a line is not found it should output two files are different and exit. The files ...