Basic Linux Commands

From SmartHPC Wiki
Jump to: navigation, search

This is just a super quick list. You need a minimum of proficiency with Unix shells (bash and tcsh are the ones mostly used on Avogadro) and Linux systems.

passwd Changes your user password.
  1. Type old password
  2. Insert new password
  3. Confirm new password
~ User's home directory.

(short-cut for: /home/username)

ls Lists folders and files in current directory
mkdir Create new directory into the current one

mkdir newdir

cd Changes directory.

Examples:
cd test (go to a directory named 'test')
cd .. (go to parent directory)
cd ~ (go to home directory)

rm Removes specified file or directory

rm filename (remove single filename)
rm *.txt (remove ALL .txt files into current directory)
rm -r dirname (remove directory and its files)

Please be careful when you use the -f option! :-)

rmdir Removes specified EMPTY directory

rmdir dirname

pwd Prints current absolute path
man Shows specified command's manual page

man ls (shows ls help)

vi x.sh VI is a text editor. If x.sh does not exists, vi creates a new file called x.sh and opens it;

otherwise, it just opens the existing file.

less textfile less is a text pager. Opens (read only) textfile file. You can use up and down arrows to move across the text, shares many commands with VI.
chmod Changes POSIX permissions of a file or directory. Allows to protect files from unwanted access.

r :read permission
w :write permission
x :exec permission

chmod +x file.sh (allows execution)
chmod -w file.sh (denies write)

chown Changes owner of a file or directory

chown username file.sh

top Shows current executing processes
cat Prints the content of a file on screen
grep Filters specified text file, and shows the lines that contains the pattern

grep pattern file.sh
You can use also pipe the output of another command:
cat file.sh |grep home
cat file.sh |grep "home page"



Further information on Linux shell can be found here:
Useful Linux Commands for Newbies - www.tecmint.com
Shell Redirection - Wikipedia
20 Advanced Commands for Middle Level Linux Users - www.tecmint.com