Most Popular

1500 questions
191
votes
21 answers

Determine the size of a block device

How can I find out the size of a block device, such as /dev/sda? Running ls -l gives no useful information.
lfaraone
  • 2,012
191
votes
7 answers

How do I delete the first n lines of an ascii file using shell commands?

I have multiple files that contain ascii text information in the first 5-10 lines, followed by well-tabulated matrix information. In a shell script, I want to remove these first few lines of text so that I can use the pure matrix information in…
Paul
  • 9,423
191
votes
7 answers

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
InquilineKea
  • 6,262
191
votes
9 answers

Why would someone choose FreeBSD over Linux?

Why would someone choose FreeBSD over Linux? What are the advantages of FreeBSD compared to Linux? (My shared hosting provider uses FreeBSD.)
ilhan
  • 2,251
191
votes
6 answers

Too many levels of symbolic links

I created this file structure: test/src test/firefox When I run this command: ln -s test/src test/firefox I would expect a symbolic link test/firefox/src to be created pointing to test/src, however I get this error instead: -bash: cd: src: Too…
191
votes
4 answers

Good detailed explanation of /etc/network/interfaces syntax?

I understood the very basic concept of how to use /etc/network/interfaces, but all I find online are examples, example after example, which I can copy-paste from. What I miss is an explanation of the syntax, an explanation of the meaning of the…
Foo Bar
  • 3,562
190
votes
9 answers

How to redirect output of wget as input to unzip?

I have to download a file from this link. The file download is a zip file which I will have to unzip in the current folder. Normally, I would download it first, then run the unzip command. wget…
190
votes
5 answers

Renumbering windows in tmux

I frequently end up with more than ten windows in tmux. Later on, I close some of my older ones. Is there a way to renumber, say window 15, to window 3 (which doesn't exist anymore)? Or to pack them all up again, so that there are no empty slots?…
dogbane
  • 29,677
190
votes
8 answers

Viewing all iptables rules

Is there a way to view iptables rules in a bit more detail? I recently added masquerade to a range of IPs: iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE service iptables save service iptables restart Which has done what I want…
189
votes
2 answers

How to create nested directory in a single command?

Apparently, it's not possible to create a nested directory in a single command? $ sudo mkdir x/y/z mkdir: cannot create directory 'x/y/z': No such file or directory
BaltoStar
  • 2,371
189
votes
3 answers

What does "systemctl daemon-reload" do?

I have a service that stopped suddenly. I tried to restart that service but failed and was asked to run: systemctl daemon-reload. What does it exactly do? What is a daemon-reload?
John
  • 1,991
188
votes
7 answers

How can I have `date` output the time from a different time zone?

I have a server running with the time zone set to UTC. It seemed like that was generally a good practice (please correct me if I'm wrong). Anyhow, one of the servers I connect to, in order to scp files, is running on EDT and stores files that I need…
cwd
  • 45,389
188
votes
5 answers

How to do I convert an animated gif to an mp4 or mv4 on the command line?

What command would I use to convert an mp4 or mv4 video file to an animated gif, and vice versa. That is, convert a animated gif to a mp4 or mv4.
stinkypyper
187
votes
6 answers

How can we run a command stored in a variable?

$ ls -l /tmp/test/my\ dir/ total 0 I was wondering why the following ways to run the above command fail or succeed? $ abc='ls -l "/tmp/test/my dir"' $ $abc ls: cannot access '"/tmp/test/my': No such file or directory ls: cannot access 'dir"': No…
Tim
  • 101,790
187
votes
6 answers

With the Linux "cat" command, how do I show only certain lines by number

If I use cat -n text.txt to automatically number the lines, how do I then use the command to show only certain numbered lines.
Geckono1
  • 1,979