
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Alphabetical Referencecat yourfile.txt cd put/target/directory/here du -hc * then it will give you this for all files in the current directory.
fgrep "words" yourfile.txt find word*
kill process killall to end multiple processes that match the name that is input.
ls -a to include invisible files. Add -l to show more information about each file such as its owner and permission flags.
mkdir directoryname nl yourfile.txt ps pwd rm yourfile.txt rmdir yourdirectory source yourfile which yourprogram $PATH). Adding an -a after which prints all instances of the program.
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 Adding your path to the command promptAdd to your.bashrc, .zshrc, or similar shell startup script:
export PS1='\w\$ ' ls. | ||||||||
| Added: | ||||||||
| > > |
Using
Tired of | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Alphabetical Reference | ||||||||
| Changed: | ||||||||
| < < | %CODE{bash}% | |||||||
| > > | %CODE{"bash"}% | |||||||
cat yourfile.txt
%ENDCODE%
Prints the contents of the given file to the console.
cd put/target/directory/here du -hc * then it will give you this for all files in the current directory.
fgrep "words" yourfile.txt find word*
kill process killall to end multiple processes that match the name that is input.
ls -a to include invisible files. Add -l to show more information about each file such as its owner and permission flags.
mkdir directoryname nl yourfile.txt ps pwd rm yourfile.txt rmdir yourdirectory source yourfile which yourprogram $PATH). Adding an -a after which prints all instances of the program.
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 Adding your path to the command promptAdd to your.bashrc, .zshrc, or similar shell startup script:
export PS1='\w\$ ' ls. | ||||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up... | ||||||||
| Changed: | ||||||||
| < < | Disk Space | |||||||
| > > | Alphabetical Reference | |||||||
| Deleted: | ||||||||
| < < | The du command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory). | |||||||
| %CODE{bash}% | ||||||||
| Deleted: | ||||||||
| < < | du -hc
%ENDCODE%
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 Adding your path to the command promptAdd to your.bashrc, .zshrc, or similar shell startup script:
export PS1='\w\$ ' Useful Unix Commands%CODE{bash}% | |||||||
cat yourfile.txt
%ENDCODE%
Prints the contents of the given file to the console.
cd put/target/directory/here | ||||||||
| Added: | ||||||||
| > > | du -hc
%ENDCODE%
Get a human-readable output of disk space usage. If you add * then it will give you this for all files in the current directory.
%CODE{bash}% | |||||||
fgrep "words" yourfile.txt
%ENDCODE%
Print only lines in a file containing the given "words" in a particular file.
find word*
kill process killall to end multiple processes that match the name that is input.
ls -a to include invisible files. Add -l to show more information about each file such as its owner and permission flags.
mkdir directoryname nl yourfile.txt ps pwd rm yourfile.txt rmdir yourdirectory source yourfile which yourprogram $PATH). Adding an -a after which prints all instances of the program. | ||||||||
| Changed: | ||||||||
| < < | Adding Directories to the PATH Variable | |||||||
| > > | Fixing Line Endings | |||||||
| Changed: | ||||||||
| < < | When you invoke commands such as python3 via at the command line, your shell searches all file directories listed in your $PATH in order to execute that command. Errors such as "command not found" when you try to run a program mean you need to add the directory containing that program to your PATH. | |||||||
| > > | If you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings. | |||||||
| Deleted: | ||||||||
| < < | To show the current directories that are in your $PATH use this: | |||||||
| %CODE{bash}% | ||||||||
| Changed: | ||||||||
| < < | echo $PATH | |||||||
| > > | tr "\r" "\n" < input.tab >.converted.tab | |||||||
| %ENDCODE% | ||||||||
| Changed: | ||||||||
| < < | To add a directory to your $PATH you can run this command | |||||||
| > > | Merging commands to be serial on TACC | |||||||
| Added: | ||||||||
| > > | Sometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core. | |||||||
| %CODE{bash}% | ||||||||
| Changed: | ||||||||
| < < | PATH=/your/directory/here:$PATH | |||||||
| > > | paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 | |||||||
| %ENDCODE% | ||||||||
| Changed: | ||||||||
| < < | %COLOR{red}%Be sure that you include the colon and the $PATH part of this. If you leave them off then your shell will not know where to look for built-in commands like ls, cd, etc.! | |||||||
| > > | Adding your path to the command prompt | |||||||
| Changed: | ||||||||
| < < | Generally, you want to add the given directory to the end or the beginning of your PATH variable list, since when you invoke a command, the directories will be searched from beginning to end and the first match will be the one that is run. Because this can lead to confusion, there is even a command you can use that gives you the path to the executable that will be run if you type a command: | |||||||
| > > | Add to your .bashrc, .zshrc, or similar shell startup script: | |||||||
| Deleted: | ||||||||
| < < | ||||||||
| %CODE{bash}% | ||||||||
| Changed: | ||||||||
| < < | which | |||||||
| > > | export PS1='\w\$ ' | |||||||
| %ENDCODE% | ||||||||
| Added: | ||||||||
| > > | Now your current working directory will show up as part of your prompt. This can save you a lot of time typing ls. | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Disk Space | ||||||||
| Changed: | ||||||||
| < < | The du command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory). | |||||||
| > > | The du command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory). | |||||||
| Changed: | ||||||||
| < < | du -hc | |||||||
| > > | %CODE{bash}% | |||||||
| Added: | ||||||||
| > > | du -hc %ENDCODE% | |||||||
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings. | ||||||||
| Changed: | ||||||||
| < < | tr "\r" "\n" < input.tab >.converted.tab | |||||||
| > > | %CODE{bash}% | |||||||
| Added: | ||||||||
| > > | tr "\r" "\n" < input.tab >.converted.tab %ENDCODE% | |||||||
Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core. | ||||||||
| Changed: | ||||||||
| < < | paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 | |||||||
| > > | %CODE{bash}% | |||||||
| Added: | ||||||||
| > > | paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 %ENDCODE% | |||||||
Adding your path to the command prompt | ||||||||
| Changed: | ||||||||
| < < | Add to your .bashrc or similar bash startup script: | |||||||
| > > | Add to your .bashrc, .zshrc, or similar shell startup script: | |||||||
| Added: | ||||||||
| > > | export PS1='\w\$ ' | |||||||
| Changed: | ||||||||
| < < | export PS1='\w\$ ' | |||||||
| > > | Useful Unix Commands | |||||||
| Changed: | ||||||||
| < < | Useful Bash CommandsThese commands are also compatible with the Terminal (Mac OS X) as well as the Windows Bash emulator called Cmder. | |||||||
| > > | %CODE{bash}% cat yourfile.txt | |||||||
| Added: | ||||||||
| > > | %ENDCODE% Prints the contents of the given file to the console. | |||||||
| Changed: | ||||||||
| < < | cat yourfile.txt Prints the contents of the given file to the console.
| |||||||
| > > | cd put/target/directory/here | |||||||
| Deleted: | ||||||||
| < < | kill process Ends a particular process. Note that you can type killall to end multiple processes that match the name that is input.
| |||||||
| Added: | ||||||||
| > > | fgrep "words" yourfile.txt find word*
kill process killall to end multiple processes that match the name that is input.
ls -a to include invisible files. Add -l to show more information about each file such as its owner and permission flags.
mkdir directoryname nl yourfile.txt ps pwd rm yourfile.txt rmdir yourdirectory source yourfile which yourprogram $PATH). Adding an -a after which prints all instances of the program. | |||||||
Adding Directories to the PATH Variable | ||||||||
| Changed: | ||||||||
| < < | When you invoke commands such as python3 via Bash, it searches all file directories listed in your PATH in order to execute that command. Errors such as "command not found" (Linux) or "not recognized as an internal or external command, operable program or batch file" (Windows) when you try to invoke something mean you need to add the directory containing that program to your PATH.
The Windows equivalent on Cmder is | |||||||
| > > |
When you invoke commands such as python3 via at the command line, your shell searches all file directories listed in your $PATH in order to execute that command. Errors such as "command not found" when you try to run a program mean you need to add the directory containing that program to your PATH. To show the current directories that are in your $PATH use this: | |||||||
| Added: | ||||||||
| > > | echo $PATH</code> $PATH you can run this command
PATH=/your/directory/here:$PATH</code> $PATH part of this. If you leave them off then your shell will not know where to look for built-in commands like ls, cd, etc.!
Generally, you want to add the given directory to the end or the beginning of your PATH variable list, since when you invoke a command, the directories will be searched from beginning to end and the first match will be the one that is run. Because this can lead to confusion, there is even a command you can use that gives you the path to the executable that will be run if you type a command:
which <command> | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Disk SpaceThedu command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory).
du -hc
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab
Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8
Adding your path to the command promptAdd to your.bashrc or similar bash startup script:
export PS1='\w\$ '
Useful Bash CommandsThese commands are also compatible with the Terminal (Mac OS X) as well as the Windows Bash emulator called Cmder.
cat yourfile.txt Prints the contents of the given file to the console.
Adding Directories to the PATH VariableWhen you invoke commands such aspython3 via Bash, it searches all file directories listed in your PATH in order to execute that command. Errors such as "command not found" (Linux) or "not recognized as an internal or external command, operable program or batch file" (Windows) when you try to invoke something mean you need to add the directory containing that program to your PATH.
The Windows equivalent on Cmder is | ||||||||
| Deleted: | ||||||||
| < < |
ContributorsDr. Jeffrey Barrick, Lucy LeBlanc | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Disk SpaceThedu command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory).
du -hc
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab
Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8
Adding your path to the command promptAdd to your.bashrc or similar bash startup script:
export PS1='\w\$ ' | ||||||||
| Added: | ||||||||
| > > |
Useful Bash CommandsThese commands are also compatible with the Terminal (Mac OS X) as well as the Windows Bash emulator called Cmder.
cat yourfile.txt Prints the contents of the given file to the console.
Adding Directories to the PATH VariableWhen you invoke commands such aspython3 via Bash, it searches all file directories listed in your PATH in order to execute that command. Errors such as "command not found" (Linux) or "not recognized as an internal or external command, operable program or batch file" (Windows) when you try to invoke something mean you need to add the directory containing that program to your PATH.
The Windows equivalent on Cmder is ContributorsDr. Jeffrey Barrick, Lucy LeBlanc | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up... | ||||||||
| Changed: | ||||||||
| < < | Disk Space | |||||||
| > > | Disk Space | |||||||
The du command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory).
du -hc | ||||||||
| Changed: | ||||||||
| < < | Fixing Line Endings | |||||||
| > > | Fixing Line Endings | |||||||
If you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.
tr "\r" "\n" < input.tab >.converted.tab
Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 | ||||||||
| Added: | ||||||||
| > > |
Adding your path to the command promptAdd to your.bashrc or similar bash startup script:
export PS1='\w\$ ' | |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Disk SpaceThedu command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory).
du -hc
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab | ||||||||
| Added: | ||||||||
| > > |
Merging commands to be serial on TACCSometimes you have 96 short jobs that you want to run serially 8 at a time on 12 cores rather than requesting 96 cores. This command will combine every 8 lines in a file into one line separated by && so that these commands are now run on one core.paste -s -d'#######\n' commands | sed "s/#/ \&\& /g" > commands8 | |||||||
| Changed: | ||||||||
| < < |
| |||||||
| > > |
| |||||||
Unix Commands Quick ReferenceUseful commands and flags that we get tired of looking up...Disk SpaceThedu command is verbose and confusing if you run it without options. Here is how to get a human-readable output and a grand total for the path argument (omit for current directory). | ||||||||
| Changed: | ||||||||
| < < | $du -hc | |||||||
| > > | du -hc | |||||||
| Added: | ||||||||
| > > |
Fixing Line EndingsIf you get odd errors after transferring a text file from a PC or Mac to a Unix machine, it's likely that you have a problem with newline characters. This is especially common when editing files in Excel and saving them to tab-delimited or comma-delimited files for input into. You can generally avoid this problem and fix the line endings by using an industrial strength text editor. This command converts Mac line endings in a saved Excel file to Unix line endings.tr "\r" "\n" < input.tab >.converted.tab | |||||||