Useful information about Linux commands.
1. The very famous "Argument list too long" issue.
When I try to copy too many files with command like
cp /blablabla/somedir/* ./
I got error like "-bash: /bin/cp: Argument list too long". The same problem appears in any command where asterisk applies to a large count of files.
An easy way to deal with it is to use find command. For instance,
find /blablabla/somedir/ -name "*" -exec cp -p {} ./ \;
2. Rather useful GUI to build find command:
http://find.unixpin.com/
3. Get information about executable files and/or shared libraries.
ldd prints the shared libraries required by each program or shared library specified on the command line.
For instance,
ldd a.out - prints out the list of *.so files on which a.out depends.
nm - list symbols from object files (for instance, can be used to get list of functions in *.so file).
file - determine file type.
For instance,
file a.out prints out the file format and target architecture (i.e. 32 or 64).
objdump - display information from object files.
For instance,
objdump -f a.out
may be used to get file format as well;
objdump -x a.out
prints out a lot of useful information.
4. How to find out Linux distribution name and version.
cat /etc/*-release - for distribution name.
uname -mrs - prints the machine hardware name, the kernel release and the kernel name. This can be used to get CPU type: CPU is 64bit if you see x86_64.
lsb_release -a - prints Linux Standard Base and distribution-specific information.
More information is available here and here.
5. lsof - list open files.
lsof -i :8000 - who is listening on the port 8000.
In addition just one another bash trick:
ReplyDeletecp -rv ~/myfolder/{folder1,folder2,folder3} ./