Most Popular

1500 questions
95
votes
6 answers

How to cause kernel panic with a single command?

Is it possible to cause a kernel panic with a single command line? What would be the most straightforward such command for a sudoing user and what would it be for a regular user, if any? Scenarios that suggest downloading something as a part of the…
Desmond Hume
  • 2,718
  • 5
  • 21
  • 21
95
votes
4 answers

How can I use column to delimit on tabs and not spaces?

I'd like to use the Unix column command to format some text. I have fields delimited by tabs, but within each field there are also spaces. column delimits on white space (tabs and spaces). How can I make column only use tabs as the delimiter? I was…
turtle
  • 2,607
  • 5
  • 19
  • 16
95
votes
20 answers

What's the easiest way to find an unused local port?

What's the easiest way to find an unused local port? Currently I'm using something similar to this: port=$RANDOM quit=0 while [ "$quit" -ne 1 ]; do netstat -a | grep $port >> /dev/null if [ $? -gt 0 ]; then quit=1 else port=`expr…
mybuddymichael
  • 1,105
  • 1
  • 7
  • 7
95
votes
4 answers

Purpose and typical usage of /etc/rc.local

The header looks like this: #!/bin/sh -e # # rc.local - executed at the end of each multiuser runlevel # # Make sure that the script will "exit 0" on success or any other # value on error. What is the reason for this file (it does not contain…
Emanuel Berg
  • 6,763
  • 7
  • 43
  • 65
95
votes
16 answers

Transfer files using scp: permission denied

I try to transfer files from remote computer using ssh to my computer : scp My_file.txt user_id@server:/Home This should put My_file.txt in the home folder on my own computer, right? I get scp/Home: permission denied Also when I try:…
Erez
  • 961
  • 1
  • 6
  • 4
95
votes
6 answers

How to COMPLETELY turn off system beep sounds forever for good for real

I use Nautilus to explore my files. I use a Debian-based OS with KDE Plasma 5. I use the keyboard a lot. When I press the key up when navigating files, if I'm already at the extremity of the list of files, Nautilus sends a big system beep which I…
Guillaume Chevalier
  • 973
  • 1
  • 7
  • 14
95
votes
11 answers

Eject USB drives / eject command

I know that the eject command can be used to eject almost any hardware component attached, but can it be used to eject USB drives? Is it possible to eject USB drives and external HDD's with the eject command?
Joe Barr
  • 1,237
  • 2
  • 12
  • 9
95
votes
8 answers

Is it possible to check where an alias was defined?

An alias, such as ll is defined with the alias command. I can check the command with things like type ll which prints ll is aliased to `ls -l --color=auto' or command -v ll which prints alias ll='ls -l --color=auto' or alias ll which also…
polemon
  • 11,133
  • 11
  • 69
  • 111
95
votes
11 answers

How do I use man pages to learn how to use commands?

While researching another problem, I came across a command, locate something | xargs -I {} bash -c "if [ -d "{}" ]; then echo {}; fi" that I wanted to learn more about. So I ran man xargs and get the following output: XARGS(1) …
user1717828
  • 3,512
  • 6
  • 23
  • 32
95
votes
1 answer

How to truncate text lines to N characters maximum?

Given a text file, or the output of a command, how can I truncate it so that every line longer than N characters (usually N=80 in a terminal) gets shorten to N characters maximum?
Totor
  • 19,302
  • 17
  • 75
  • 102
95
votes
8 answers

Using jq to extract values from column-oriented JSON and format in CSV

I have the below JSON file, with the data stored as columns enumerated by rank in an array: { "data": [ { "displayName": "First Name", "rank": 1, "value": "VALUE" }, { "displayName": "Last Name", "rank":…
Kerim
  • 951
  • 1
  • 6
  • 3
95
votes
15 answers

Removing control chars (including console codes / colours) from script output

I can use the "script" command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) with "col -b", but I can't find a simple way to…
95
votes
7 answers

How to read first and last line from cat output?

I have text file. Task - get first and last line from file after $ cat file | grep -E "1|2|3|4" | commandtoprint $ cat file 1 2 3 4 5 Need this without cat output (only 1 and 5). ~$ cat file | tee >(head -n 1) >(wc -l) 1 2 3 4 5 5 1 Maybe awk…
dmgl
  • 1,083
  • 2
  • 10
  • 9
95
votes
8 answers

How to download a folder from google drive using terminal?

I want to download a folder from my google drive using terminal? Is there any way to do that? I tried this: $ wget "https://drive.google.com/folderview?id=0B-Zc9K0k9q-WWUlqMXAyTG40MjA&usp=sharing" But it is downloading this text file:…
user22180
  • 1,123
  • 1
  • 8
  • 8
95
votes
9 answers

Use system clipboard in vi-copy mode in tmux

I'm running tmux 1.6 and I'm trying to configure it to use vi-style keybindings as well as use the system clipboard when copying in interactive mode: set-window-option -g mode-keys vi bind-key -t vi-copy 'v' begin-selection bind-key -t vi-copy 'y'…
Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311