Most Popular

1500 questions
83
votes
9 answers

How do I shorten the current directory path shown on terminal?

If I am in a deep directory, let's say: ~/Desktop/Dropbox/School/2017/C/A3/ then when I open up terminal, it says bob@bob-ubuntu:~/Desktop/Dropbox/School/2017/C/A3/$ and then I write my command. That is very long, and every line I write in the…
K Split X
  • 1,733
83
votes
2 answers

What does dead.letter files do

I find dead.letter files from time to time in my $HOME directory. What they are for?
83
votes
8 answers

grep and tail -f?

Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
xenoterracide
  • 59,188
  • 74
  • 187
  • 252
83
votes
13 answers

Why write an entire bash script in functions?

At work, I write bash scripts frequently. My supervisor has suggested that the entire script be broken into functions, similar to the following example: #!/bin/bash # Configure variables declare_variables() { noun=geese count=three } #…
Doktor J
  • 2,622
83
votes
3 answers

How to enable reverse search in zsh?

I recently switched to zsh (finally) and am loving it! So far one thing that I am missing is Ctrl+R to do incremental history search. I have the history set up properly HISTSIZE=10000 SAVEHIST=10000 HISTFILE=~/.zsh_history and I used vi key…
Ali
  • 6,943
83
votes
11 answers

Using sftp to Transfer a Directory?

When I try to use sftp to transfer a directory containing files, I get an error message: skipping non-regular file directory_name The directory contains a couple of files and two subdirectories. What am I doing wrong?
haziz
  • 2,241
83
votes
3 answers

lsof and listening ports

I am trying to get all the processes listening for a network connection on Mac OS X. netstat does not have the -p option and I am trying with lsof lsof -i -sTCP:LISTEN gives me a fair list of listening processes but not all. I can for example…
Matteo
  • 9,796
  • 4
  • 51
  • 66
83
votes
3 answers

Can I force dnf to install an old version of a package?

I want to install an older version of package , and when I use dnf it only shows the current version of the package . Is there any way to install an older versions using dnf ?
0x0584
  • 1,352
83
votes
4 answers

Copy file to xclip and paste to Firefox

I'm coping file to xclip cat file.txt | xclip I'm pasting without problem with xclip -o When I want to paste it to Firefox with Ctrl+V it pastes old text (that shouldn't already be in the clipboard). When I go back to terminal and run xclip -o it…
xralf
  • 15,415
83
votes
12 answers

How to disable line wrap in a terminal?

I need to view large logs files using a bash shell. I was using less to open the files, but since the lines are too lengthy there is some kind of line/word wrapping going on. Since the files are Log4J logs, and there is a pattern in the beginning…
nunaxe
  • 1,003
83
votes
15 answers

How to color diff output?

I wanted to format the Unix files conditionally, I am currently working on diff command and wanted to know if it is possible to format the text of the diff command output. Example: Matched values should be displayed in green. Unmatched values…
Aman
  • 1,201
83
votes
6 answers

Listing packages in Yum that depend on another installed package

I am trying to install a 3rd-party RPM package on RHEL5 which depends on version 3.4 of sqlite. According to Yum I already have 3.3.6 installed. Is there a way to list the installed packages that depend on sqlite 3.3.6?
Rich
  • 4,529
83
votes
3 answers

How does /usr/bin/env know which program to use?

When I use the shebang #!/usr/bin/env python to run a script, how does the system know which python to use? if I look for a python bin path in the environment variables I find nothing. env | grep -i python
tMC
  • 1,185
82
votes
8 answers

rsync all files of remote machine over SSH without root user?

I have this command to backup a remote machine. The problem is that I need root rights to read and copy all files. I have no root user enabled for security reasons and use sudo the Ubuntu way. Would I need some cool piping or something to do…
redanimalwar
  • 1,057
82
votes
4 answers

How to list processes locking file?

Using flock, several processes can have a shared lock at the same time, or be waiting to acquire a write lock. How do I get a list of these processes? That is, for a given file X, ideally to find the process id of each process which either holds, or…
Benubird
  • 5,912