COMMANDS

Sr. No. Command Purpose/Details Example
1 php -m [PHP Modules] : List all modules
2 ulimit -a List out the limit of user
3 vim /etc/security/limits.conf Change the limit of user variable
4 nohup Run a Command or Shell-Script Even after You Logout nohup java -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar > output.log 2>&1 &
5 ll -d */ List all directory
6 rsync -arC rsync -arC working_directory working_directory_no_svn It will dump all files and folders without svn in another directory.
7 top display and update the top cpu processes
8 mpstat 1 display processors related statistics
9 vmstat 2 display virtual memory statistics
10 mysql -u root -p Connect to the mysql server through command prompt
11 ps axjf All processes in a tree format
12 df display free disk space and mounted devices
13 du -sh * Directory sizes as listing
14 du -csh Total directory size of the current directory
15 du -ks * | sort -n -r Sort everything by size in kilobytes
16 ls -lSr Show files, biggest last
17 cp -avr folder1 folder 2 Copy one folder and its file to another folder
18 Solr Run in a terminal in foreground java -Dsolr.solr.home="./example-DIH/solr/" -jar start.jar
19 sudo do-release-upgrade -d Update the current version with new version
20 cat /etc/apt/sources.list List out all repository which will be updated or upgraded from these servers
21 sudo update-manager -d try to upgrade to the latest release of Ubuntu
22 zip -r filename.zip directory_to_zip_recursively
23 unzip unzip filename.zip
24 zip zip files exluding some files and folder zip -r squeakee.zip * -x zip/ -x sq_oldsite/ -x solr/ -x staging/ -x logs/*
zip -r squeakee.zip * -x zip/* sq_oldsite/* solr/* staging/* logs/*
25 How to determine whether a given Linux is 32 bit or 64 bit? “cat /proc/cpuinfo” or we can use “getconf LONG_BIT. “ If we want to check the system architecture ie 32 bit or 64 bit , not for the Linux kernel, but for the CPU.
25 cp -avr folder1 folder 2 cp -r (file to copy) (where to copy) Substitute the brackets with the necessary path. The ‘r’ option allows you to go recursively into the folder. The ‘r’ option allows you to go recursively into the folder.
27 updatedb updatedb To update the linux database for localy search
28 tail tail myfile.txt Delivers the last part of the file. The above example would list the last 10 (default) lines of the file myfile.txt.
tail myfile.txt -n 100 The above example would list the last 100 lines in the file myfile.txt.
tail -f myfile.txt This next example displays the last 10 lines and then update the file as new lines are being added. This is a great command to use to watch log files or logs in real-time.
29 find . -name pro*  if we want to find all the files that start with “pro” in the Documents directory, we would use the “cd Documents/” (without the quotes) command to change to the Documents directory, and then type the following command.
30 How to set Cron sudo crontab -u ubuntu -e */10 * * * * /usr/bin/php /var/www/prafulkr/cJobCRMCron.php > /var/www/logs/cronlogShadow.txt 2>&1
*/04 * * * * /usr/bin/php /var/www/prafulkr/latLongProcessCron.php > /var/www/logs/latLongProcessCronLog.txt 2>&1
*/21 * * * * /usr/bin/php /var/www/prafulkr/deltaImportCron2.php > /var/www/logs/cronlogproduction.txt 2>&1
*/25 * * * * /usr/bin/php /var/www/prafulkr/deltaImportCron2.php > /var/www/logs/deltaImportAppCronLog.txt 2>&1
31 lspci listout all drivers
32 sudo sed -i ‘/extras.ubuntu.com/d’ /etc/apt/sources.list sudo sed -i ‘/extras.ubuntu.com/d’ /etc/apt/sources.list To disable the extras repositories, just remove all the extras entries from /etc/apt/sources.list file or use the software sources and untick the extras entries there.
33 Search in linux grep -nHlrE — sq_offers_bkp
34 uname -r uname -r Find the version on Linux
35 lsb_release -a lsb_release -a Find Distribution Version
33 uptime In Linux uptime command shows since how long your system is running and the number of users are currently logged in and also displays load average for 1,5 and 15 minutes intervals. Check Uptime Version-
Uptime command don’t have other options other than uptime and version. It gives information only in hours:mins if it less than 1 day.
34 w It will displays users currently logged in and their process along-with shows load averages. also shows the login name, tty name, remote host, login time, idle time, JCPU, PCPU, command and processes. Available options:
-h : displays no header entries.
-s : without JCPU and PCPU.
-f : Removes from field.
-V : (upper letter) – Shows versions.
35 users Users command displays currently logged in users. This command don’t have other parameters other than help and version.
36 who who command simply return user name, date, time and host information. who command is similar to w command. Unlike w command who doesn’t print what users are doing. Lets illustrate and see the different between who and w commands. Who command Options:
-b : Displays last system reboot date and time.
-r : Shows current runlet.
-a, –all : Displays all information in cumulatively.
37 whoami whoami command print the name of current user. You can also use “who am i” command to display the current user. If you are logged in as a root using sudo command “whoami” command return root as current user. Use “who am i” command if you want to know the exact user logged in.
38 ls -l ls command display list of files in human readable format.
39 ls -ltr Sort file as per last modified time.
40 crontab -l List schedule jobs for current user with crontab command and -l option.
41 crontab -e Edit your crontab with -e option. In the below example will open schedule jobs in VI editor. Make a necessary changes and quit pressing :wq keys which saves the setting automatically.
42 less install.log less command allows quickly view file. You can page up and down. Press ‘q‘ to quit from less window.
43 more install.log more command allows quickly view file and shows details in percentage. You can page up and down. Press ‘q‘ to quit out from more window.
44 cp -p fileA fileB Copy file from source to destination preserving same mode.
45 cp -i fileA fileB You will be prompted before overwrite to file.
46 mv -i fileA fileB Rename fileA to fileB. -i options prompt before overwrite. Ask for confirmation if exist already.
47 cat fileA fileB cat command used to view multiple file at the same time.
48 cat install.log | less You combine more and less command with cat command to view file contain if that doesn’t fit in single screen / page.
49 cat install.log | more You combine more and less command with cat command to view file contain if that doesn’t fit in single screen / page.
50 cd /fileA with cd command (change directory) it will goes to fileA directory.
51 pwd pwd command return with present working directory.
52 sort fileA.txt Sorting lines of text files in ascending order. with -r options will sort in descending order.
53 sort -r fileA.txt Sorting lines of text files in ascending order. with -r options will sort in descending order.
54 vi -R /etc/shadows Vi is a most popular text editor available most of the UNIX-like OS. Below examples open file in read only with -R option. Press ‘:q‘ to quit from vi window.
55 ssh narad@192.168.50.2 SSH command is used to login into remote host. For example the below ssh command will connect to remote host (192.168.50.2) using user as narad.
56 ssh -V To check the version of ssh use option -V (uppercase) shows version of ssh.
57 ftp 192.168.50.2 ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).
58 sftp 192.168.50.2 ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).
59 ftp > mput *.txt ftp or sftp command is used to connect to remote ftp host. ftp is (file transfer protocol) and sftp is (secure file transfer protocol). For example the below commands will connect to ftp host (192.168.50.2).
60 ftp > mget *.txt Putting multiple files in remote host with mput similarly we can do mget to download multiple files from remote host.
61 service httpd start Service command call script located at /etc/init.d/ directory and execute the script. There are two ways to start the any service. For example we start the service called httpd with service command.
62 /etc/init.d/httpd start Service command call script located at /etc/init.d/ directory and execute the script. There are two ways to start the any service. For example we start the service called httpd with service command.
63 free Free command shows free, total and swap memory information in bytes.
64 free -t Free with -t options shows total memory used and available to use in bytes.
65 top -u tecmint top command displays processor activity of your system and also displays tasks managed by kernel in real-time. It’ll show processor and memory are being used. Use top command with ‘u‘ option this will display specific User process details as shown below. Press ‘O‘ (uppercase letter) to sort as per desired by you. Press ‘q‘ to quit from top screen.
66 tar -cvf archive-name.tar /home tar command is used to compress files and folders in Linux. For example the below command will create a archive for /home directory with file name as archive-name.tar.
67 tar -xvf archive-name.tar To extract tar archive file use the option
68 grep tecmint /etc/passwd grep search for a given string in a file. Only tecmint user displays from /etc/passwd file. we can use -i option for ignoring case sensitive.
69 find / -name tecmint Find command used to search files, strings and directories. The below example of find command search tecmint word in ‘/‘ partition and return the output.
70 lsof -u tecmint lsof mean List of all open files. Below lsof command list of all opened files by user tecmint.
71 last With last command we can watch user’s activity in the system. This command can execute normal user also. It will display complete user’s info like terminal, time, date, system reboot or boot and kernel version. Useful command to troubleshoot.
72 last tecmint You can use last with username to know for specific user’s activity
73 ps -ef | grep init ps command displays about processes running in the system. Below example show init process only.
74 kill- 9 7508 Use kill command to terminate process. First find process id with ps command as shown below and kill process with kill -9 command.
75 rm filename rm command used to remove or delete a file without prompting for confirmation.
76 rm -i test.txt Using -i option to get confirmation before removing it. Using options ‘-r‘ and ‘-f‘ will remove the file forcefully without confirmation.
77 mkdir directoryname mkdir command is used to create directories under Linux.
78 ls -ltr With combination of -ltr will shows latest modification file or directory date as last.
79 ls -lS With combination of -lS displays file size in order, will display big in size first.
80 ls -i We can see some number printed before file / directory name. With -i options list file / directory with inode number.
81 ls -l /tmp With ls -l command list files under directory /tmp. Wherein with -ld parameters displays information of /tmp directory.
82 ls -n To display UID and GID of files and directories. use option -n with ls command.
83 alias ls="ls -l" We have made alias for ls command, when we execute ls command it’ll take -l option by default and display long listing as mentioned earlier.
84 unalias ls To remove an alias previously defined, just use the unalias command.
85 ls -F Using -F option with ls command, will add the ‘/’ Character at the end each directory.
86 ls -r The following command with ls -r option display files and directories in reverse order.
87 ls -lh With combination of -lh option, shows sizes in human readable format.
88 tailf it will display the files contect by automaticaly scrolling
89 Jobs / jobs -l List the current jobs
90 & We can start any job in back ground by putting & and the end of the job
91 Xeyes & I am going to run a command called xeyes that displays two googly eyes on screenI started a job in the background with an ampersand (&). The shell prints a line that looks like the following
92
93 sudo dpkg-reconfigure tzdata If We want to change the time zone then we need to run this command and set the proper time zone. Set or change the time zone.
94 How do I extract a gz file? Use guzip command as follows: $ gunzip file.gz OR $ gzip -d file.gz
95 How do I extract a tar.gz or .tgz file? Files with extension tar.gz or .tgz are tar files compressed with gzip. On Unix system extract them with following command: $ gunzip < file.tar.gz | tar xvf -
$ gunzip < file.tgz | tar xvf -

If you have GNU tar (Linux system) you can use the z option directly:
$ tar xvzf file.tar.gz
$ tar xvzf file.tgz
‘tar jxf filename.tar.bz2
Open a terminal and type:
tar xvjf filename.tar.bz2
Which will untar it to the current directory. Normally (99% of the time) it will create it’s own subdirectory so you don’t need to worry about that.
Just so you know:
tar – Tape ARchiver
And the options:
x – extract
v – verbose output (lists all files as they are extracted)
j – deal with bzipped file
f – read from a file, rather than a tape device

"tar –help" will give you more options and info
to extract in from .bz2 , use below
bzip2 -cd files.tar.bz2 | tar xvf -
and to compress into .bz2 , use below
bzip2 -cd files.tar.bz2 | tar tvf -

96 dpkg –get-selections | grep -v deinstall To get a list of packages installed locally do this in your terminal:
97 sudo apt-get autoremove To get rid of stale packages
98 dpkg -l | grep ii and you can get the list of the installed packages with just a command:
99 apt log you can look at the apt log under /var/log/apt/ the dpkg log under /var/log/
100 sudo apt-get install imagemagick Installing Imagemagic
101
102
103
104
105
106
107
108 sudo aplay -l What to do when sound is not comming properly https://help.ubuntu.com/community/SoundTroubleshooting
exiting on signal 15. Server rebooted with "signal 15"
Server automatically rebooted
What does exiting on signal 15 mean in /var/log/messages?
Some crashes, in particular those involving the X server, are impossible to reproduce on the text console. The best way is then to use a second computer from which you can log in to the "sick" machine using ssh.
On the "sick" machine, install openssh-server (make sure you have good passwords on all user accounts if your machine is connected to the Internet). On the second machine, install openssh-client. If this is a Windows machine, install Putty, a free SSH client. If it is a MacOSX machine, it already has the ssh client installed.
Find the IP address of the sick machine, for instance by running ip addr. If both machines are running Ubuntu 7.04 or MacOSX, you can use the machine name (e.g. mycomputer.local) instead of the IP address. Connect to the sick machine, for instance ssh myuser@192.168.1.3
Inside the ssh session, run sudo cat /proc/kmsg Optionally start a second ssh session to run for instance tail -f /var/log/syslog or other commands. You can emulate the above SysRq key presses, for instance the Alt+SysRq+t combination, by running  echo t | sudo tee /proc/sysrq-trigger
Reproduce the crash Watch any error messages in the ssh client window on the second machine, and save them to a file that you attach to the bug report.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>