lshw: list hardware information snapshot
———————-
cat /proc/version: show the Linux version
———————-
rm`ls -1 | grep -v ‘precious$’ | xargs` -rf
: remove all files/folders in current directory except ‘precious’; ls -1 list all in a column; -rf removes without confirmation
———————-
rm -i `ls -1 | grep -v ‘\.abc$’ | grep -v ‘\.xyz$’ | xargs`
: remove all files in current directory except files with extension ‘.abc’ or ‘.xyz’; -i prompts for confirmation for each deletion
———————-
rm `find | grep .ext | xargs`
: remove all files with extension’.ext’, in current folder and all subfolders.
———————-
useful gcc debug options:
`-print-search-dirs’
: Print the name of the configured installation directory and a list of program and library directories gcc will search–and don’t do anything else.
———————-
mount remote directory
sudo apt-get install sshfs
sudo modprobe fuse
sudo adduser username fuse
sudo chown root:fuse /dev/fuse
sudo chmod +x /dev/fuse(rmout?)
logout and login again
mkdir ~/remoteserv
sshfs username@ipaddress:/remotepath ~/remoteserv
———————-
show size of folders
du –max-depth=1 “somedir” | sort -n -r
du -h –max-depth=1 “somedir”
———————-
count the number of files in a certain folder:
ls “somedir” | wc -l
———————-
ldd “some_binary”
: list the dependency for “some_binary” file. It’s very useful to correct some mis-linked libraries.
———————-
remove a long list of files.
rm is the most frequently used command to remove a bunch of files, however, sometimes we would see this message “rm: Argument list too long”. What I would guess is the way ‘rm’ is implemented is that it first creates a list of file names with string and then iterates through the list to delete each file. Therefore, it’s reasonable to set an upper-bound.
A good workaround, I found from google is : find <some dir> -name “<some pattern>” -print | xargs rm
Before you use this command, run this first to check if they are actually the files you are looking for: find “some dir” -name “some pattern” | more
———————-
Add user access to afs directories(could be used for cvs project sharing)
fs sa <directory> <username> <permission>
fs la: to list access information
to remove someone’s access and recursively:
find . -type d -print | xargs fs setacl -acl <username> none -dir
———————-
Shell for statement
e.g.
for ((i=1; i<1000; i++))
do
qdel $i
done
———————-
# rename every *.htm file *.html
for f in *htm ; do mv $f `basename $f htm`html; done”
———————-
List only directories:
ls -d */
———————-
Redirecting stdout and stderr to file:
1) stderr to file:
e.g. foo 2> file.out
2) stdout to file:
e.g. foo > file.out
3) stdout and stderr to file:
e.g. foo &> file.out
———————-
A link to some handy commands(will update to my list when tried each):
http://www.daniweb.com/forums/thread1743.html