Most Popular

1500 questions
174
votes
4 answers

How can I execute local script on remote machine and include arguments?

I have written a script that runs fine when executed locally: ./sysMole -time Aug 18 18 The arguments "-time", "Aug", "18", and "18" are successfully passed on to the script. Now, this script is designed to be executed on a remote machine but, from…
AllenD
  • 2,467
174
votes
10 answers

How to chmod without /usr/bin/chmod?

Today I was told a tale by a Unix trainer where the root password got leaked to the students, and one of the fellas removed the execute permission from /usr/bin/chmod itself. How do you recover chmod in this case and make it executable again? Let's…
Sundar R
  • 1,598
174
votes
10 answers

How can I find the hardware model in Linux?

I used a system information utility to take the model number of a system, and also of the motherboard. DMI System Manufacturer LENOVO DMI System Product 2306CTO DMI System Version ThinkPad X230 DMI Motherboard Product …
174
votes
2 answers

How does systemd use /etc/init.d scripts?

I just switched to debian jessie, and most things run okay, including my graphical display manager wdm. The thing is, I just don't understand how this works. Obviously my /etc/init.d/wdm script is called, because when I put an early exit in there,…
174
votes
15 answers

diff within a line

I have some sql dumps that I am looking at the differences between. diff can obviously show me the difference between two lines, but I'm driving myself nuts trying to find which values in the long list of comma-separated values are actually the ones…
user394
  • 14,404
  • 21
  • 67
  • 93
173
votes
9 answers

Fix terminal after displaying a binary file

I'd tried command cat with an executable file: cat /bin/ls Now I can't read any word in this terminal (Linux console). How can I fix it?
lotusirous
  • 3,669
173
votes
20 answers

A standard tool to convert a byte-count into human KiB MiB etc; like du, ls1

Is there a standard tool which converts an integer count of Bytes into a human-readable count of the largest possible unit-size, while keeping the numeric value between 1.00 and 1023.99 ? I have my own bash/awk script, but I am looking for a…
Peter.O
  • 32,916
173
votes
9 answers

Why use swap when there is more than enough free space in RAM?

Using swap space instead of RAM can drastically slow down a PC. So why, when I have more than enough RAM available, does my Linux system (Arch) use the swap? Checkout my conky output below: Also, could this be the cause of speed and…
Stefan
  • 25,300
173
votes
8 answers

Can scp create a directory if it doesn't exist?

I want to use scp to upload files but sometimes the target directory may not exist. Is it possible to create the folder automatically? If so, how? If not, what alternative way can I try?
AGamePlayer
  • 7,605
172
votes
5 answers

What is the difference between "sort -u" and "sort | uniq"?

Everywhere I see someone needing to get a sorted, unique list, they always pipe to sort | uniq. I've never seen any examples where someone uses sort -u instead. Why not? What's the difference, and why is it better to use uniq than the unique flag to…
Benubird
  • 5,912
171
votes
11 answers

Delete First line of a file

How can I delete the first line of a file and keep the changes? I tried this but it erases the whole content of the file. $sed 1d file.txt > file.txt
kickass13
  • 1,783
  • 3
  • 12
  • 5
171
votes
6 answers

How do I read from /proc/$pid/mem under Linux?

The Linux proc(5) man page tells me that /proc/$pid/mem “can be used to access the pages of a process's memory”. But a straightforward attempt to use it only gives me $ cat /proc/$$/mem /proc/self/mem cat: /proc/3065/mem: No such process cat:…
171
votes
3 answers

Why is number of open files limited in Linux?

Right now, I know how to: find open files limit per process: ulimit -n count all opened files by all processes: lsof | wc -l get maximum allowed number of open files: cat /proc/sys/fs/file-max My question is: Why is there a limit of open files in…
xanpeng
  • 5,725
171
votes
2 answers

Zip everything in current directory

I'd like to compress and package everything, including files and folders in current directory, into a single ZIP file on Ubuntu. What would be the most convenient command for this (and name of the tool needed to be installed if any)? Edit: What if I…
Terry Li
  • 1,955
171
votes
1 answer

What does the "@" (at) symbol mean on OSX ls?

When I check permission of less files from the command line on my Snow Leopard OSX system using Bash I see -rw-r--r--@ for certain files and for others I just see -rw-r--r-- What does the @ mean here?
rhand
  • 1,875