Friday, 14 September 2018

Commands & tool for working in C environment


Cscope

·         find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.xml" -o -name "Makefile" -name "makefile" > cscope.files

·         cscope -q -R -b -i cscope.files

·         ctags -L cscope.files   -> this is working.



Vim:

·         To move next line based on previous line

o    Set cintend

·         To highlight the white space

/\s\+$

:set hlsearch

Or  

:match Error /\s\+$/

·         To count the selected word

o    :%s/pattern//gn

·         Replance from current cursor position:

o    .,$s/conn/connLow/gc     => "."  is considered as the current position.



·         Diff in the console with | symbol to notify diff, not vimdiff, tool is diff

o    diff -y summary.txt -y output/summary.txt

·         Control+W followed by W to toggle between open windows and,



Notepad ++:

·         Short cut for go to specific line

o    Ctrl + g

o    To block select like VIM, similar to ctrl + v in VIM

o    ctrl + alt + shift and then left click mouse





Coverity:

1.       Coverity line between 2 diff with duplicate lines

Replace branch name in another file

sort tmp_857 | uniq -c > sort_tmp_857

sort tmp_fresh | uniq -c > sort_temp_fresh

vimdiff sort_tmp_fresh  sort_tmp_857


Find:

·         To list the extention of file from this path

o    find . -type f -name "*.*" | awk -F. '{print $NF}' | sort -u



·         To list specific file

o    find -regex ".*\.\(jpg\|gif\|png\|jpeg\)"





Grep:

·         To display a multiple pattern

grep -E 'foo|bar' *.txt

EG: Top command to display 2 var=> top | grep -E 'Mem|CPU|tcpdump|Load'

·         To search backslash

grep -r \\\\ *

·         To list only the file name

grep -l

·         To display the next 3 line from the founded word

grep -A 3 FORWARD_NULL folder_name_857.txt

·         To display line before & After

o    grep's -A 1 option will give you one line after;

o    -B 1 will give you one line before;

o     -C 1combines both to give you one line both before and after.

·         To search only header files:

o    grep -ri --include \*.h *





X11 -> display

Xauth list -> to list the authenticate cookies



Below command to remove all entries in xauth to resolve "X11 proxy: MIT-MAGIC-COOKIE-1 data did not matchError" Error

 xauth list | cut -f1 -d\  | xargs -i xauth remove {}



LS:

To list the KB or MB

Ls --block-size=k for KB,

Ls --block-size=m for MB.



Other Unix command:

·         To list the file details

file -L /usr/lib/libpcap.so.1

·         du -sh * => will display the all folder with used size

·         du -sh * | sort -h   ==> to sort in order.

·         lsb_release -a => to know the Ubuntu version(Eg: 14.0)

·         Convert Linux txt file into windows format:

o     perl -p -e 's/\n/\r\n/' < test > dosfile3.txt

·         Empty the contents of a file:

o    cp /dev/null <file Name to empty>

·         Remove the stray value " error: stray ‘\302’ in program" or error: stray ‘\240’ in program from .c file.

o    tr -cd '\11\12\15\40-\176' < old.c > new.c

·         Unzip the file:

o    Run file access-2.log.gz, it will tell you the compression type.

·         EG: $file tmp.gz

         tmp.gz: 8086 relocatable (Microsoft)

·         To know the default gateway

ip route | grep default

·         To know the DNS is resolving or not

o    nslookup google.com   => It should return the google.com ip

·         Iptables & conntrack

o    To list the conntrack entries

·         conntrack –L

·         conntrack -L -p tcp --dport 80

o    To delete the entries in conntrack

·         conntrack -D

o    To delete Input rule

·         iptables -L -n -v --line-number

·         iptables -D INPUT 3

o    To delete POSTROUTING:

·         iptables -t nat -L -n -v --line-number

·         iptables -t nat -D POSTROUTING 2

o    Command to list:

·         iptables -L

·         iptables -L -n  => For INPUT, FORWARD and OUTPUT-chains

·         iptables -L -t nat

·         iptables -t nat -L -n -v  -> to View nat rules



Screen:

          screen -S <user name> => To create a new screen.

screen -x <name>   => To open an existing screen.

screen -ls    => To list the available screen

ctrl + a+c   => to create a new window inside the screen.

ctrl +a + d  => To come out from the screen.

Ctrl + a + A  => To rename the current window.

F1      => move backside window inside the screen

F2      => Move forward window inside the screen.

Screen -L -x <name >   => Open the session with saving the logs in home dir.





Tools:

Ss->  socket statistics.

netstat command reads various /proc files but ss gets its information directly from kernel space, so good.

ss -ap | grep high => give the ipc socket details with process id.

-u => udp   (IPC socket is not udp because it don’t have any layer 3 IP)

-t => tcp

-a => all

Visio -> is a tool for msoffice to use UML diagram.

nm -> to find the function name in binary =>  nm -A nsh  | grep nsh_sdb_connect

Objdump -> used to find function name but our ARM architecture not supporting.

arm-elf-objdump -> not installed

arm-elf-objdump -D -b binary -marm binaryfile.dat



Ldd:

You can list the shared library dependencies which your executable is dependent

abuser@labuser-virtual-machine:~/velrajk/sample/ipc_soc/API$ ldd cli

        linux-vdso.so.1 =>  (0x00007ffd4d38e000)

        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6c03f7b000)

        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6c03bb3000)

        /lib64/ld-linux-x86-64.so.2 (0x00007f6c04199000)

labuser@labuser-virtual-machine:~/velrajk/sample/ipc_soc/API$



·         Wing ftp:

o    It’s a trial software supports ftps server.

o    Create new domin &  new user, give the ftp directory path while creating user.

o    Domain is the FTP server or HTTP server running port

o    User is the ftp login username, while connecting to this ftp need to give this user details for login.

o    Windows defender firewall or any firewall on windows PC should be disabled.







Linux troubleshoot:

Firefox not opening:

sudo chown labuser:labuser .Xau*

rm .Xauthority-c

rm .Xauthority-1


No comments:

Post a Comment