Answer: - ls -l | grep ^- | sort -nr
Question: List the hidden files in current directory ?
Answer: - ls -a1 | grep "^\."
Question: Delete blank lines in a file ?
Answer: - cat sample.txt | grep -v ‘^$’ > new_sample.txt
Question: Search for a sample string in particular files ?
Answer: - grep “Debug” *.confHere grep uses the string “Debug” to search in all files with extension“.conf” under current directory.
Question: Display the last newly appending lines of a file during appendingdata to the same file by some processes ? - tail –f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.
Question: Display the Disk Usage of file sizes under each directory in currentDirectory ? - du -k * | sort –nr (or) du –k . | sort -nr
Change to a directory, which is having very long name ? - cd CDMA_3X_GEN*Here original directory name is – “CDMA_3X_GENERATION_DATA”.
Question: Display the all files recursively with path under current directory ? - find . -depth -print
Question: Set the Display automatically for the current new user ?
Answer: - export DISPLAY=`eval ‘who am i | cut -d"(" -f2 | cut -d")" -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
Question: Display the processes, which are running under yourusername ?
Answer: - ps –aef | grep MaheshvjHere, Maheshvj is the username.
Question: List some Hot Keys for bash shell ?
Answer: - Ctrl+l – Clears the Screen. Ctrl+r –
Question: Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a – Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently running process into background.
Question: Display the files in the directory by file size ?
Answer: - ls –ltr | sort –nr –k 5
How to save man pages to a file ? - man
Question: How to know the date & time for – when script is executed ?
Answer: - Add the following script line in shell script.eval echo "Script is executed at `date`" >> timeinfo.infHere, “timeinfo.inf” contains date & time details ie., when script is executed and history related to execution.
Question: How do you find out drive statistics ?
Answer: - iostat -E
Question: Display disk usage in Kilobytes ?
Answer: - du -k
Question: Display top ten largest files/directories ?
Answer: - du -sk * | sort -nr | head
Question: How much space is used for users in kilobytes ?
Answer: - quot -af
Question: How to create null file ? - cat /dev/null > filename1
Access common commands quicker ? - ps -ef | grep -i $@
Question: Display the page size of memory ?
Answer: - pagesize -a
Question: Display Ethernet Address arp table ?
Answer: - arp -a
Question: Display the no.of active established connections to localhost ? - netstat -a | grep EST
Question: Display the state of interfaces used for TCP/IP traffice ?
Answer: - netstat -i
Question: Display the parent/child tree of a process ?
Answer: - ptree
Question: Show the working directory of a process ?
Answer: - pwdx
Question: Display the processes current open files ?
Answer: - pfiles
Question: Display the inter-process communication facility status ?
Answer: - ipcs
Question: Display the top most process utilizing most CPU ?
Answer: - top –b 1
Question:Alternative for top command ?
Answer: - prstat –a
No comments:
Post a Comment