Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why do people fear writing passwords in the command line?

The history file is located in ~/.history, so it's available only to the user who executed the commands (and root).

share|improve this question
2  
You can avoid to log some commands in your history file. See the answers in Avoid to keep command in history –  Luc M Jun 8 '13 at 21:06
4  
Yuk! Even if you define your password with export mypass=secret and you use a_command --password=$mypass, you'll see secret in ps table. –  Luc M Jun 8 '13 at 21:12

3 Answers 3

up vote 46 down vote accepted

Command lines are not just available in history. They are also available, for example, in the output of ps -ocmd or through the /proc filesystem. (/proc/<pid>/cmdline) which is where ps reads them.

Also, users' home directories are often world- or group- readable; you can make the history file only user-readable, but that might not survive deletion and recreation.

share|improve this answer

Passwords on the command line are just a bad idea all the way around. In addition to the methods discussed in the other answers:

  • /proc
  • process list (ps)
  • user's history file

User commands can show up in these locations as well:

  • audit logs
  • /var/log/*

In addition user's commands can also show up when users login between systems, so in general it's a bad practice and should be avoided at all times.

share|improve this answer
2  
+1 for the /var/log reference - note that often the important system logs can be sent elsewhere, and don't necessarily stay on the same system. Thus your passwords may inadvertently also be transmitted across the network in cleartext form. –  Mark Glossop Jun 14 '13 at 1:33

The problem is the visibility of the parameters (to other users in most cases, even for root) while the command is running. See the output of

ps -eo pid,user,args
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.