Most Popular

1500 questions
169
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,609
  • 5
  • 17
  • 11
169
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,935
  • 2
  • 17
  • 14
169
votes
6 answers

Argument string to integer in bash

Trying to figure out how to convert an argument to an integer to perform arithmetic on, and then print it out, say for addOne.sh: echo $1 + 1 >>sh addOne.sh 1 prints 1 + 1
user135986
  • 1,699
  • 2
  • 10
  • 3
169
votes
7 answers

Get SSH server key fingerprint

Is there a way to programmatically obtain a SSH server key fingerprint without authenticating to it? I'm trying ssh -v user@host false 2>&1 | grep "Server host key", but this hangs waiting for a password if key based auth is not setup.
loopbackbee
  • 4,442
  • 3
  • 24
  • 30
169
votes
3 answers

Shell scripting: -z and -n options with if

I have a shell script where we have following lines if [ -z "$xyz" ] and if [ -n "$abc" ], but I am not sure what their purpose is. Can anyone please explain?
user3173953
  • 1,799
  • 2
  • 11
  • 3
168
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,397
  • 4
  • 17
  • 14
168
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,752
  • 10
  • 36
  • 41
168
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 …
Eduard Florinescu
  • 11,153
  • 18
  • 57
  • 67
168
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:…
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
168
votes
4 answers

What exactly is POSIX?

I see POSIX mentioned often and everywhere, and I had assumed it to be the baseline UNIX standard.. until I noticed the following excerpt on a Wikipedia page: The Open Group The Open Group is most famous as the certifying body for the UNIX …
Peter.O
  • 32,426
  • 28
  • 115
  • 163
168
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,845
  • 2
  • 12
  • 10
167
votes
7 answers

Why does find -mtime +1 only return files older than 2 days?

I'm struggling to wrap my mind around why the find interprets file modification times the way it does. Specifically, I don't understand why the -mtime +1 doesn't show files less than 48 hours old. As an example test I created three test files with…
Mike B
  • 8,769
  • 24
  • 70
  • 96
167
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,595
  • 7
  • 24
  • 20
167
votes
6 answers

What's the meaning of a dot before a command in shell?

While following android eclipse debug tutorial, I encounter following commands. cd /path/to/android/root . build/envsetup.sh lunch 1 make emulator My problem is what the dot before build/envsetup.sh means?
Jichao
  • 1,897
  • 2
  • 13
  • 8
166
votes
10 answers

How can I use ffmpeg to split MPEG video into 10 minute chunks?

There is often a need in the open source or active developer community to publish large video segments online. (Meet-up videos, campouts, tech talks...) Being that I am a developer and not a videographer I have no desire to fork out the extra…
Gabriel
  • 1,763
  • 2
  • 11
  • 8