• Blog
  • Research
  • The Linux Learning Curve

    21 January, 2019 | General Hackery

    The great thing about Linux - and indeed Unix, and other systems too - is that you're always learning. There are so many little things that you pick up all the time. Despite using Linux for about 20 years, I've learned two commands only recently that I didn't know before but are now an essential part of my arsenal.


    This command lets you know the absolute location of the file you're calling if it's in your path. For example, you might just type 'python [filename]' to run a python script, but you might also want to run it from cron, which won't have your path variable set. So typing 'which python' will return '/usr/bin/python', or wherever your current Python interpreter is installed.


    I've always known about the history command, which gives you a history of every command you've typed. But reading the man page shows that this command is much more powerful than that. Let's say - as I do often - I've just logged into a server for which I have SSH keys set up. Absent mindedly, and without thinking, I type my username, then my password. Whoops! I've just entered my password into a command prompt and it's now in the history for all to see (or at the very least, for root to see). If you make this mistake, type history and look for your password in the list, and there will be a line number next to it. Now type history -d [line number] to remove the offending line, and history -w to write the log to .bash_history, and no-one need ever know you did anything quite so daft.