Skip to content

u/lsblk

In this archive from Mar 2016 to May 2016

0
posts
323
comments
0
media
739
score

Top comments

Security. You could be tricked into executing a file in your current working directory if you were allowed to execute them without the ./ prefix.

You have two environment variables in Bash: PATH (where executables are) and PWD (print working directory, the current directory you're in). In order to execute a program - say, cat - when you type cat at the prompt Bash checks all the directories in the PATH environment variable. If it finds it, then it runs the program. If you were just allowed to type cat to execute a script in your current directory, then PWD would have to be added to path, which would mean it could execute a file in your current directory called cat.

./cat ensures that you are deliberately executing a file called cat in your current working directory, and there is no confusion about the command you're issuing.

62 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.