Linux
Linux commands
Starting and Stopping httpd
https://docs.fedoraproject.org/en-US/Fedora/12/html/Deployment_Guide/s1-apache-startstop.html
- To start the server using the apachectl control script as root type:
apachectl start
- To stop the server, as root type:
apachectl stop
- You can restart the server as root by typing:
apachectl restart or: /sbin/service httpd restart
- You can also display the status of your httpd server by typing:
apachectl status
unzip tar.gz file
tar -xvzf community_images.tar.gz
To explain a little further, tar collected all the files into one package, community_images.tar. The gzip program applied compression, hence the gz extension. So the command does a couple things:
f: this must be the last flag of the command, and the tar file must be immediately after. It tells tar the name and path of the compressed file. z: tells tar to decompress the archive using gzip x: tar can collect files or extract them. x does the latter. v: makes tar talk a lot. Verbose output shows you all the files being extracted.
VNC Server
How to Setup VNC Server
Step 1: Install Required Packages For CentOS/RHEL 6:
# yum groupinstall "Desktop"
For CentOS/RHEL 5:
# yum groupinstall "GNOME Desktop Environment" # yum install pixman pixman-devel libXfont
Step 2: Install VNC Server
# yum install vnc-server
Step 3: Connect VNC Server using VNC Viewer
vncserver - start or stop a VNC server
Synopsis
vncserver [:display#] [-name desktop-name] [-geometry widthxheight] [-depth depth] [-pixelformat format] [-fp font-path] [-fg] [-autokill] [Xvnc-options...] vncserver -kill :display# vncserver −list
vncpasswd - change the VNC password
Synopsis
vncpasswd [passwd-file] vncpasswd -f
$ vncpasswd Password: Verify:
Docker commands
ssh root@devops
https://docs.docker.com/engine/reference/commandline/exec/
docker exec -it dockername bash cd /root/so docker exec -it dockername bash docker exec -it --user=root devdb bash
https://docs.docker.com/engine/reference/commandline/logs/
docker logs -f dockername
docker restart dockername
show all dockers
docker ps docker ps -a (Show all containers)
Recover dump file in docker
sftp://devdb.webbfontaine.am/home/user //Put your dmp files here minioclient cp wfs3/bhqa/twm/db/1538024414.dmp dump.dmp sudo su docker cp backup/dump.dmp devdb:/dump.dmp docker exec -it --user=root devdb bash OR docker exec -it --user=0 devdb bash ON ERROR OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "chdir to cwd (\"/home/oracle\") set in config.json failed: permission denied": unknown docker exec --interactive --tty --user root --workdir / dockername bash cd / mv /backup.dmp opt/oracle/admin/YOUR_SID/dpdump/ cd opt/oracle/admin/YOUR_SID/ chown -R dockername dpdump/
show all UID
[root@52c17fb398f9]# awk -F: '{printf "%s:%s\n",$1,$3}' /etc/passwd root:0 bin:1 daemon:2 adm:3 lp:4 sync:5 shutdown:6 halt:7 mail:8 operator:11 games:12 ftp:14 nobody:99 systemd-bus-proxy:999 systemd-network:192 dbus:81 sshd:74 oracle:1000 rpc:32 rpcuser:29 nfsnobody:65534
Midnight Commander
http://klimer.eu/2015/05/01/use-midnight-commander-like-a-pro/
create file
Shift + F4 - Create a new file
Selecting files
Insert (Ctrl + t alternatively) - select files (for example, for copying, moving or deleting). + - select files based on a pattern. \ -unselect files based on a pattern. * - reverse selection. If nothing was selected, all files will get selected.
Accessing the shell
Alt + Enter - copy the currently selected file’s name to the shell.
Panels
Alt + t - switch the panel’s listing mode in a loop: default, brief, long, user-defined. “long” is especially useful, because it maximises one panel so that it takes full width of the window and longer filenames fit on screen. Alt + i - synchronize the active panel with the other panel. That is, show the current directory in the other panel. Ctrl + u - swap panels. Alt + y - move to the previous directory in history. Alt + u - move to the next directory in history.
Searching files
Alt + ? - shows the full Find dialog. Alt + s or Ctrl + s - quick search mode. Start typing and the selection will move to the first matching file. Press the shortcut again to jump to another match. Use wildcards (*, ?) for easier matching.
Common actions
Ctrl + Space - calculate the size of the selected directories. Press this shortcut when the selection is on .. to calculate the size of all the directories in the current directory. Ctrl + x s (that is press Ctrl + x, let it go and then press s) - create a symbolic link (change s to l for a hardlink). I find it very useful and intuitive - the link will, of course, be created in the other panel. You can change it’s destination and name, like with any other file operation. Ctrl + x c - open the chmod dialog. Ctrl + x o - open the chown dialog.
Bonus assignments
Compare directories (Ctrl + x d)
SSH connection problem with “Host key verification failed…” error "Host key verification failed" means that the host key of the remote host was changed.
Ssh stores the host keys of the remote hosts in ~/.ssh/known_hosts. You can either edit that text file manually and remove the old key (you can see the line number in the error message), or use
ssh-keygen -R hostname
Working with CSV
Repeat a Linux Command Every X Seconds
while true; do wc -l SAD_SEL_TRACK_DATA_TABLE.csv ; sleep 5; done
Get only the first row using head command:
$ head -1 myfile.csv 1,2,3,4,5
Get the count of lines in a csv file
1) wc -l filename.csv 2) cat DATA_TABLE.csv | wc -l 3) awk '{n+=1} END {print n}' DATA_TABLE.csv
the following command will print all of the lines of the file DATA_TABLE.csv that begin with a # character: grep -v "#" DATA_TABLE.csv | wc -l
Remove particular symbol from CSV
this remove " from TABLE.csv and create new file TABLE2.csv
sed 's/\"//g' TABLE.csv > TABLE2.csv
Where can I find the Java SDK in Linux?
This depends a bit from your package system ... if the java command works, you can type readlink -f $(which java) to find the location of the java command
Copy all files from remote server exclude excel files
rsync -av -e ssh --exclude='*.xls' --exclude='*.xlsx' remoteuser@remotehost:/from_folder /to_folder