Questions tagged [unix]
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.
3,992
questions
1741
votes
10
answers
1.6m
views
How can I sort the output of 'ls' by last modified date?
How can I sort the output of ls by last modified date?
668
votes
18
answers
761k
views
How to copy with cp to include hidden files and hidden directories and their contents?
How can I make cp -r copy absolutely all of the files and directories in a directory
Requirements:
Include hidden files and hidden directories.
Be one single command with an flag to include the ...
644
votes
41
answers
559k
views
How to execute a command whenever a file changes?
I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I'm finished working with ...
579
votes
7
answers
772k
views
What is the "You have new mail" message in Linux/UNIX?
Sometimes, when I log into a box and 'su' to root, I get a cute little message saying I have mail (thank GOD it's not AOL).
Where is this mail?
What does it contain?
Who/What sent it?
How important ...
431
votes
9
answers
896k
views
How to get the summarized sizes of directories and their subdirectories?
Let's say I want to get the size of each directory of a Linux file system. When I use ls -la I don't really get the summarized size of the folders.
If I use df I get the size of each mounted file ...
413
votes
3
answers
1.0m
views
What is the Windows equivalent of the Unix command cat?
I want to do exactly what unix "cat" does, but on my PC. Is there a simple equivalent command for the Windows command line?
Specifically I want to create a file from all the files of a given type in ...
401
votes
7
answers
1.0m
views
How can I make chown work recursively?
I've got a directory called pdfs that contains a bunch of sub- and sub-sub-directories. I want to change ownership on all PDF files in all of the subfolders. I just tried this:
chown -R someuser:...
397
votes
13
answers
287k
views
How can I search the bash history and rerun a command?
Can I search history in bash and run the result?
388
votes
7
answers
149k
views
less command with multiple files: How to navigate to next/previous
I just found out I can use less with multiple files. less status line tells me
(END) - Next: file2.txt
But how do I navigate previous/next from less?
358
votes
11
answers
778k
views
If I know the PID number of a process, how can I get its name?
If I have the PID number for a process (on a UNIX machine), how can I find out the name of its associated process?
What do I have to do?
325
votes
5
answers
374k
views
How can I find files that are bigger/smaller than x bytes?
In a terminal, how can I find files that are bigger or smaller than x bytes?
I suppose I can do something like
find . -exec ls -l {} \;
and then pipe the result to awk to filter by file size. But ...
276
votes
20
answers
341k
views
Unix/Linux find and sort by date modified
How can I do a simple find which would order the results by most recently modified?
Here is the current find I am using (I am doing a shell escape in PHP, so that is the reasoning for the variables):
...
269
votes
7
answers
276k
views
When should I use /dev/shm/ and when should I use /tmp/?
When should I use /dev/shm/ and when should I use /tmp/? Can I always rely on them both being there on UNIX?
264
votes
6
answers
130k
views
Choosing between .bashrc, .profile, .bash_profile, etc [duplicate]
This is embarrassing, but after many years of using POSIX systems full time, I still have a hard time figuring out if a shell customization should go in .bashrc, .profile, or somewhere else. Not to ...
258
votes
5
answers
385k
views
How to find files with certain text in the Terminal
I'd like to find all files that contain a certain string of text. How would you do that in the Terminal?
254
votes
8
answers
331k
views
Unix zip directory but excluded specific subdirectories (and everything within them)
I'm trying to zip a directory (on Unix via SSH) but I need to exclude a couple of subdirectories (and all files and directories within them).
So far I have this:
zip -r myarchive.zip dir1 -x dir1/...
253
votes
8
answers
24k
views
What do the parentheses and number after a Unix command or C function mean?
I keep seeing parentheses and a number after a command in Unix or Linux or C function.
For example: man(8), ftok(2), mount(8), etc.
What do these mean? I see them in man too.
251
votes
35
answers
296k
views
Is there a way to display a countdown or stopwatch timer in a terminal?
How can I display a real-time countdown timer on the Linux terminal? Is there an existing app or, even better, a one liner to do this?
236
votes
3
answers
98k
views
What does the 'rc' in `.bashrc`, etc. mean? [duplicate]
Well, this is embarrassing. I feel like I just realised I don't know a loyal colleague's name after working with them for 10 years. "Hey, er... *cough!*, thanks for that great job you did on setting ...
226
votes
12
answers
66k
views
How can I change to the previous directory instead of going up?
I currently spend a lot of my working hours moving back and forth between two paths which are very far down the tree and divert from each other at root. It strikes me that my life would be a lot ...
223
votes
6
answers
345k
views
What's different between Ctrl+Z and Ctrl+C in Unix command line?
I'm using Mac OS X Terminal. And I use Ctrl+Z or Ctrl+C to stop some programs. But I realized that I don't know what they're exactly doing. What are they and what's the difference between them?
...
220
votes
18
answers
51k
views
What is the advantage of using 'tar' today?
I know that tar was made for tape archives back in the day, but today we have archive file formats that both aggregate files and perform compression within the same logical file format.
Questions:
...
210
votes
9
answers
216k
views
How do I configure SSH so it doesn't try all the identity files automatically?
I have been putting my ssh identity files inside my ~/.ssh/ folder. I have probably about 30 files in there.
When I connect to servers, I will specify the identity file to use with something like
...
209
votes
17
answers
268k
views
Is there a way to see any tar progress per file?
I have a couple of big files that I would like to compress. I can do this with for example
tar cvfj big-files.tar.bz2 folder-with-big-files
The problem is that I can't see any progress, so I don't ...
204
votes
6
answers
483k
views
How to close a tmux session
I am using tmux to manage multiple terminal windows. Currently I have 2 windows open with multiple panes.
I know that I have to use the prefix (for me it is ctrl+a) to enter commands.
How can I ...
203
votes
9
answers
22k
views
How far will you get with an 'rm -rf /' command?
I've often wondered how far the system will actually get if you run rm -rf /. I doubt the OS would be able to erase itself (?)
Bonus Question: After the command has been executed, will rm have ...
197
votes
10
answers
138k
views
PowerShell equivalent to the Unix `which` command?
Does PowerShell have an equivalent to the which command found in most (if not all) Unix shells?
There are a number of times I'd like to know the location of something I'm running from the command ...
197
votes
10
answers
249k
views
How do I set up SSH so I don't have to type my password?
How do I set up SSH so I don't have to type my password when connecting to a host?
196
votes
10
answers
302k
views
List the current folder folder's sizes with the terminal?
I want a list of the folders from the current directory or one that I specify with their size.
I have tried with du but I only get the size of the directories I specify (du . ./f1), and ls doesn't ...
192
votes
5
answers
316k
views
Compress files from OS X terminal?
In the Finder, there is this wonderful ability to right click on a file or directory, select compress from the drop-down, and end up with a zipped file.
Is it possible to do the same thing from the ...
184
votes
5
answers
184k
views
How to run Unix commands from within Vim?
How can I run Unix commands while I'm inside vim?
170
votes
10
answers
629k
views
ls-command: how to display the file size in megabytes?
In Unix (Tru64), how do I make the ls command show the file size in megabytes? Currently I am able to show it in bytes using the following:
ls -la
168
votes
4
answers
117k
views
How to use spaces in a bash alias name?
I am trying to create an aliases in bash. What I want to do is map ls -la to ls -la | more
In my .bashrc file this is what I attempted:
alias 'ls -la'='ls -la | more'
However it does not work ...
157
votes
5
answers
56k
views
which/whereis differences
What's the difference between which and whereis ?
148
votes
5
answers
19k
views
How does Linux know that the new password is similar to the previous one?
A few times I tried to change a user password on various Linux machines and when the new password was similar to the old one, the OS complained that they were too similar.
I always wondered, how does ...
137
votes
6
answers
49k
views
How do I reload .inputrc?
Background
I have heard that the readline module is reading ~/.inputrc and that is how it changes the behaviour of keystrokes under programs such as bash.
Question
How can I reload this after ...
136
votes
4
answers
229k
views
What is effect of CTRL + Z on a unix\Linux application
I was curious and confused that what exactly is the behaviour of ctrl+z.
I know, If a process in running in foreground, and we press ctrl+z, it goes to background.
But what exactly happens?. Does it ...
135
votes
3
answers
254k
views
What is the "wheel" user in macOS/OS X?
I recently reinstalled iTunes and I noticed something peculiar.
The original version of iTunes has a user in the permissions known as wheel that is set to "Read Only".
I dragged this version ...
134
votes
4
answers
155k
views
How do file permissions apply to symlinks?
Let's say you have this structure:
+ directory
-- file1
-- file2
-- file3 -> /tmp/file3
file3 is a link to another file3 somewhere else on the system.
Now let's say I chmod 777 the directory and ...
131
votes
4
answers
130k
views
How does one switch between windows on VIM?
I'm using both Vim and MacVim (or well, trying to). I installed the Tagbar plugin but find it impossible to switch to the actual Tagbar window to make my selection.
I've been reading loads about ...
125
votes
2
answers
69k
views
How to start vim without executing /etc/vimrc?
On my Linux server at work, the admins did not install cscope, and I installed it from source in my home directory and added it to the $PATH. The trouble is, the /etc/vimrc has a reference to /usr/...
123
votes
3
answers
220k
views
How do I gunzip to a different destination directory?
How do I gunzip to a destination directory other than the current one?
This did not work:
gunzip *.gz /putthemhere/
120
votes
18
answers
18k
views
What's the quickest way to count the number of each character in a file?
I want to count the A's T's C's G's N's and "-" characters in a file, or every letter if needed, is there a quick Unix command to do this?
120
votes
12
answers
120k
views
How to sort first directories then files etc… when using “ls” in Unix
I would like to use the ls command to first show directories and then files. I tried:
ls -la | sort -k 1
But I got a wrong order.
117
votes
3
answers
384k
views
What is the .bashrc file?
Unix shells when starting read the .bashrc file and execute commands written in it. What is this file and what does it execute?
116
votes
5
answers
171k
views
Check if any of the parameters to a bash script match a string
I'm trying to write a script where I want to check if any of the parameters passed to a bash script match a string. The way I have it setup right now is
if [ "$3" != "-disCopperBld" -a "$4" != "-...
115
votes
2
answers
71k
views
Why does Windows use backslashes for paths and Unix forward slashes?
It annoys me having used Unix in college and now working on the Windows side. What's the history behind this decision? Anyone know why it worked out this way?
114
votes
4
answers
28k
views
'less' command clearing screen upon exit - how to switch it off?
How to force the less program to not clear the screen upon exit?
I'd like it to behave like git log command:
it leaves the recently seen page on screen upon exiting
it does not exit the less even ...
113
votes
9
answers
127k
views
On Linux/Unix, does .tar.gz versus .zip matter?
Cross-platform programs are sometimes distributed as .tar.gz for the Unix version and .zip for the Windows version. This makes sense when the contents of each must be different.
If, however, the ...
113
votes
6
answers
43k
views
What is the origin of the UNIX $ (dollar) prompt?
The UNIX prompt uses a $ symbol to indicate that your input is expected.
I was wondering why this symbol was chosen—if there is a reason. Dollar just seems a little unexpected. A > symbol would ...