Linux

Unix bash commands

Directories

pwd
print current working directory (where I am now)
cd -
go to the previous directory you were in (command-line equivalent of the back button)
ls -l
list files in current directory using a long listing format
ls -d */
list only subdirectories in the current one
du -sh *
size of each file in the current directory
du -sh .
size of the current directory
mkdir
make directory
rmdir
remove directory
fs setacl -dir . -acl rosa rl
give me permission to read and list the content in the current directory (also give listing permission to all top directories)
fs listacl
list the permission for this directory (also fs listacl /afs/hep.man.ac.uk/u/rosa/hoppet/hacked/include)

Files

mv folder_name/* .
move all content from the folder folder_name to the current working directory
cp /dir1/file.cpp{,-old}
equivalent to cp /dir1/file.cpp /dir1/file.cpp-old
rm -rf
(force to) remove files recursively
chmod +x file.sh
make file.sh executable

Tarballs

tar czvf myfolder.tar.gz abcfolder/
compress the directory abcfolder and create the archive file myfolder.tar.gz
tar -zxvf file.tar.gz
uncompress tarball

Grep

grep -n -e word File
print the lines in File that include the text word, -e as a regular expression, -n give the number of the line
history | grep word
search the bash history for lines that match the text word
ls -R | grep word
search in the recursive listing of directories for the text word

Processes

top
list users and processes running on the system
Ctrl-c
terminate a running program
xkill
kill a crashed graphic interface

System

cat /etc/issue
distribution of Linux installed in the system

Server

ssh -X -Y user@host
login on a remote host. (-X -Y to enable trusted X11 display)
scp -r dir_host:/directory
secure copy (-r for recursive) to a directory at remote host
kinit -R
(if your site is using the Kerberos login program) keep logged in, for 24 hours (similar to klog)
fs quota
percentage of quota used of my home area

Extra

&
(at the end of a command) the shell remains active after the command is executed
&&
string multiple commands together (ex. cd .. && make clean && make)

Reference

Built-in & Shell tools for GNU Linux & OS X
Unix Basics


Comments

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License