Hacker Public Radio

HPR3882: Alternatives to the cd command


Listen Later

Five or six ways I could think of to roam the files of your Linux computer without cd.
pushd and popd dirs
https://en.wikipedia.org/wiki/Pushd_and_popd
The pushd command, when called with a filepath as an argument, saves
the current working directory in memory (via a directory stack) so it
can be returned to at any time, places the new filepath at the top of
the stack, and changes to the new filepath. The popd command returns to
the path at the top of the directory stack.
cd -
From man bash An argument of - is converted to $OLDPWD
before the directory change is attempted.
Variables
EXPORT mydir="/path/to/file/"
cd ${mydir}
History and histverify
Using !number from the history command will execute the command
[user@pc ~]$ history
1 cd tmp
2 cd ~
3 history
[user@pc ~]$ !3
cd tmp
[user@pc tmp]$
from the man command
shopt [-pqsu] [-o] [optname ...]
Toggle the values of settings controlling optional shell behavior.
...
-s Enable (set) each optname.
-u Disable (unset) each optname.
Now using !number from the history command will put the command on
the prompt but you need to execute it yourself
[user@pc ~]$ shopt -s histverify
[user@pc ~]$ !39673
[user@pc ~]$ cd tmp
autocd command
[ken@kalani ~]$ shopt -s autocd
[ken@kalani ~]$ tmp
cd -- tmp
[ken@kalani tmp]$ ~
cd -- /home/ken
working without changing
to directory
[ken@kalani ~]$ ls tmp
...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

289 Listeners

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec by Jerry Bell and Andrew Kalat

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec

373 Listeners

LINUX Unplugged by Jupiter Broadcasting

LINUX Unplugged

268 Listeners

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast) by Johannes B. Ullrich

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast)

653 Listeners

Curious Cases by BBC Radio 4

Curious Cases

826 Listeners

The Strong Towns Podcast by Strong Towns

The Strong Towns Podcast

422 Listeners

Late Night Linux by The Late Night Linux Family

Late Night Linux

164 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,035 Listeners

Cybersecurity Today by Jim Love

Cybersecurity Today

181 Listeners

CISO Series Podcast by David Spark, Mike Johnson, and Andy Ellis

CISO Series Podcast

189 Listeners

TechCrunch Daily Crunch by TechCrunch

TechCrunch Daily Crunch

42 Listeners

Strict Scrutiny by Crooked Media

Strict Scrutiny

5,799 Listeners

2.5 Admins by The Late Night Linux Family

2.5 Admins

98 Listeners

Cyber Security Headlines by CISO Series

Cyber Security Headlines

139 Listeners

What the Hack? by DeleteMe

What the Hack?

221 Listeners