Linux commands

From Microwiki
Jump to: navigation, search

List of a few Miscellaneous commands

  1. ps -eaf
    lists all processes running on a machine
  2. sed -i s/SNM/SNM_V1/ file1
    Find and replace in file
  3. find . -name "*.cdslck"
    To find a file
    dot means from current folder
  4. uniq
    shows one of each instance
  5. to reverse the order of lines in a file using: cat -n temp3.file | sort -r -n | cut -d ':' -f2 > my_output_file
  6. find and delete all simulation result files (example here for tran.tran files)
    find . -type f -name "tran.tran" -exec rm {} \;
    Delete all directories named "psf":
    find . -name "psf" -type d -print0 | xargs -0 rm -r --
  7. SCP command -- The following command copies the folder Downloads from /srv/holl/ home directory to the local folder on the desktop from which i run the following command
    scp -r username@ ./
  8. ls_colors setting for dark background (for c shell)
    setenv LS_COLORS 'di=01;34'
  9. VNC command
    vncserver :5 -depth 24 -geometry 1366x768
  10. Installing rpm (e.g. flashplayer)
    rpm -Uvh filename.rpm
  11. Find and copy the files
    find . -name "*foobar*" -exec cp "{}" ~/foo/bar \;
  12. PDF utility: pdftk
    Join (or merge) in1.pdf and in2.pdf into a new PDF, out1.pdf
    >pdftk in1.pdf in2.pdf cat output out1.pdf
  13. Restart http or apache when you make changes to website related files
    As root, type
    >/etc/init.d/httpd restart
  14. List all widths in a netlist:
    grep "^M" filename | cut -d' ' -f8 | sort | uniq
  15. Search recursively (inside directories) in files with specific extension
    grep -r --include "*.tex" searchstring .
  16. Conditioning output of ocean script -- AWK usage example
    grep "^# VDD =" sa_offset_meas_vddi_raw_data -n | cut -d':' -f1 | awk '($1!=p+1){print $1-p-1} {p=$1}'
    awk explanation:
    $1 is the first column from current input line
    p is the previous value of the last line
    so ($1!=p+1) is a condition:if $1 is different than previous value +1, then :
    this part is executed : {print p+1 "-" $1-1} : print previous value +1, the - character and fist columns + 1
    {p=$1} is executed for each lines : p is assigned to the current 1st column
    Find difference in line numbers of occurrence -- last value must be manually done, as no reference exists
  17. Free memory in Hollerith:
    sync; echo 3 > /proc/sys/vm/drop_caches
    (requires root access)
  18. Zipping and unzipping a file:
    Zip: $tar cvfz filename.tar.gz file_to_zip
    Unzip: $tar xvfz filename.tar.gz
  19. List of commands to run (as root) to allow vncserver access onto Fedora 18 machine (not perfect, but works):
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5902 -j ACCEPT
service iptables save
service iptables restart