This helped me find a botnet that had made into my system. Of course, this is not a foolproof or guarantied way to find all of them or even most of them. But it helped me find it.
readlink -f accepts a relative, noncanonical path and emits the corresponding canonical, absolute path. Show Sample Output
This revision to my command (command #8851) was called for when it failed to find the parent package of 'rlogin', which is really a deep symbolic link to /usr/bin/ssh. This revision fixes this newfound issue, while ensuring fixes of other older issues work too. Show Sample Output
Part of coreutils - so needs no extra package... Show Sample Output
Also resolves symlinks, showing the full path of the link target
Retrieve absolute path name from relative path Show Sample Output
Advanced revision to the command 8776 . This revision follows symbolic links. The quotation-marks surrounding $(which $1) allows for graceful handling of errors ( ie. readlink does not complain incase 'which' command generates (null) output) Show Sample Output
shell function which allows you to tag files by creating symbolic links directories in a 'tags' folder.
The tag function takes a tag name as its first argument, then a list of files which take that tag. The directory $HOME/tags/tagname will then hold symbolic links to each of the tagged files. This function was modified from bartonski's (http://www.commandlinefu.com/commands/view/10216) inspired by tmsu (found at https://bitbucket.org/oniony/tmsu/wiki/Home) with readlink function by flxndn (http://www.commandlinefu.com/commands/view/10222).
Example:
tag dog airedale.txt .shizturc weimeraner.pl
This will create $HOME/tags/dog which contains symbolic links to airedale.txt .shizturc and weimeraner.pl
After you run this script, you can check status for broken symlink with this command: find -L . -type l
The "type" builtin command is handy to find out what executable will be used if you issue a command. But on some distros, particularly when using /etc/alternatives, certain executables get buried under layers and layers of symbolic links and it becomes hard to find which one. If you put the above command in your .bashrc, it adds a "-c" option to the type command that will weed through the symbolic links and prints the actual file that will be executed. Show Sample Output
Ever tried to mess with links and/or ../ in the file path? This command outputs the fully resolved path to the actual file passed on the command line.
You can use the command "full" not only with one item, with items with diferent paths, and with relatives and absolute paths.
It gives a 'xcd' command for changing directory to one of CWDs of other ZSH processes (typically running in a terminal emulator). Useful for single-windowed terminal emulators like XTerm or Rxvt which don't have ability to pass CWD of one shell to another. Show Sample Output
'readlink -fn' gets canonical path of the file/directory without newline at the end; 'xsel -ib' copies pipelined string from STDIO to system clipboard (ready to be pasted with CTRL+V). Show Sample Output
grep -v '\(/dev/\|pipe:\|socket:\)' seemingly looks a bit complicated. This can, of course, be replaced by head -1. However, it is not sure whether the filename line will be first on all systems, so I chose the safer way by filtering out what is not needed here. Show Sample Output
This command stores data in the following files: files.txt, links.txt
Find and read all symbolic links in /path1 and stores list in links.txt
find /path1 -type l -exec readlink -f {} \; > links.txt
Find all files in /path2 and stores list in files.txt
find /path2 -type f > files.txt &&
Displays lines in files.txt that do not exist in links.txt
grep -Fxv -f links.txt files.txt
Show Sample Output
Uses the pid to get the full path of the process. Useful when you do not which command got picked from the path Show Sample Output
work for execute file
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: