Most Popular

1500 questions
98
votes
11 answers

How to test whether a file uses CRLF or LF without modifying it?

I need to periodically run a command that ensures that some text files are kept in Linux mode. Unfortunately dos2unix always modifies the file, which would mess file's and folder's timestamps and cause unnecessary writes. The script I write is in…
Adam Ryczkowski
  • 5,493
  • 7
  • 39
  • 60
98
votes
12 answers

git pull from remote but no such ref was fetched?

I have a git mirror on my disk and when I want to update my repo with git pull it gives me error message: Your configuration specifies to merge with the ref '3.5/master' from the remote, but no such ref was fetched. It also gives me: …
Micromega
  • 4,201
  • 5
  • 27
  • 34
98
votes
1 answer

Make cd follow symbolic links

I have my code mounted as an sshfs in my home directory, but the hierarchy is difficult to remember, so I created a symlink in my home directory leading to that directory. Is there a way so that when I cd to that symbolic link, instead of cding to…
rowantran
  • 1,805
  • 2
  • 13
  • 7
98
votes
5 answers

Bash throws error, line 8: $1: unbound variable

I am trying to learn how to use getopts so that I can have scripts with parsed input (although I think getopts could be better). I am trying to just write a simple script to return partition usage percentages. The problem is that one of my bash…
Timothy Pulliam
  • 3,549
  • 3
  • 21
  • 42
98
votes
8 answers

Have rm not report when a file is missing?

I have a bash script that I want to remove files from various directories. Frequently, they won't be there because they weren't generated and that's fine. Is there a way to get the script not to report that error, but if rm has some other output to…
flickerfly
  • 1,581
  • 1
  • 11
  • 13
98
votes
11 answers

How do I create a blank PDF from the command line?

I recently needed a single blank PDF page (8.5" x 11" size) and realized that I didn't know how to make one from the command line. Issuing touch blank.pdf produces an empty PDF file. Is there a command line tool that produces an empty PDF page?
Brian Fitzpatrick
  • 2,755
  • 3
  • 23
  • 43
98
votes
11 answers

Is there a way to stop having to write 'sudo' for every little thing in Linux?

I'm going to be doing a fair amount of PHP work shortly, and I'm interested in learning RoR, so I installed Linux Mint 12 in my VirtualBox. The most frustrating aspect of the switch, so far, has been dealing with Linux permissions. It seems like I…
Major Productions
  • 1,105
  • 1
  • 8
  • 12
98
votes
2 answers

What does status "active (exited)" mean for a systemd service?

I'm working with a custom service which essentially runs a web server, called thisismywebserver. Currently it's not working (ie I get an "Unable to Connect" error trying to access a page). When I run this command service thisismywebserver status to…
Highly Irregular
  • 2,455
  • 6
  • 23
  • 24
98
votes
3 answers

sudo as another user with their environment

$ whoami admin $ sudo -S -u otheruser whoami otheruser $ sudo -S -u otheruser /bin/bash -l -c 'echo $HOME' /home/admin Why isn't $HOME being set to /home/otheruser even though bash is invoked as a login shell? Specifically,…
user80551
  • 1,549
  • 3
  • 15
  • 21
98
votes
5 answers

Pasting X selection (not clipboard contents) with keyboard

I'd like to be able to paste the X selection using the keyboard. Currently I have to use the middle mouse button to do this. I gather that faking a middle mouse button press is fairly easy to do, but such a solution would also require moving the…
intuited
  • 3,488
  • 3
  • 25
  • 36
97
votes
5 answers

The result of ls * , ls ** and ls ***

I know using the command ls will list all the directories. But what does the ls * command do ? I used it and it just lists the directories. Does the star in front of ls mean how deep it will list the directories?
Andy M
  • 1,083
  • 1
  • 9
  • 7
97
votes
5 answers

How to check available package versions in rpm systems?

If I want to check available versions of a package in Debian, I run apt-cache policy pkgname which in the case of wajig gives: wajig: Installed: 2.01 Candidate: 2.01 Version table: *** 2.01 0 100 /var/lib/dpkg/status 2.0.47 0 …
tshepang
  • 64,472
  • 86
  • 223
  • 290
97
votes
7 answers

Is there a simple command for outputting tab-delimited columns?

E.g. I have a file (produced with echo -e "var1\tvar2\t\var3\tvar4" > foo) that are output as: $ cat foo case elems meshing nlsys uniform 2350 0.076662 2.78 non-conformal 348 0.013332 0.55 scale 318 0.013333 …
Sebastian
  • 8,677
  • 4
  • 39
  • 49
97
votes
6 answers

Clear unused space with zeros (ext3,ext4)

How to clear unused space with zeros ? (ext3,ext4) I'm looking for something smarter than cat /dev/zero > /mnt/X/big_zero ; sync; rm /mnt/X/big_zero Like FSArchiver is looking for "used space" and ignores unused, but opposite site. Purpose: I'd…
Grzegorz Wierzowiecki
  • 13,865
  • 23
  • 89
  • 137
97
votes
2 answers

Why is my bash prompt getting bugged when I browse the history?

Often when I start looking at history of commands some of the characters from a command displayed aren't erased, for example: What's happening: prompt$ some_command prompt$ some_commanother_command What should have happened: prompt$…
korda
  • 1,561
  • 1
  • 12
  • 14