Monday, December 21, 2015

Fun with Linux

1) Remove ^M
    $vi file.txt

2) 64 bit or 32 bit?
    $uname -a
    $more /proc/cpuinfo

3) Copy and preserving the same mode including timestamp
    $cp -p a.txt b.txt
    $cp -a a b

4) Who logged, from where?
    $last myuserid

5) Compiling C++ code?
    $g++ -shared ...
    $g++ -static-libgcc -L. -o hello hello.cpp
    $ar mylib.a mylib.o

6) Sort in reverse order (find, grep,...)
    $sort -r file.txt

7) To show free, total, and swap memory info in bytes
    $free -t

8) List top processes?
    $top -u myuserid

9) Backup or transfer files?
    $tar cvf a.tar /subdir
    $tar xvf a.tar

10) List all open files?
    $lsof -u myuserid

No comments:

Post a Comment