Last active
January 7, 2023 12:15
-
-
Save NaserKhoshfetrat/3d4600f4e70309b0236f10cacd89f0f6 to your computer and use it in GitHub Desktop.
linux command sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################################################################################### | |
##os-centos-7## | |
#get centos version | |
$cat /etc/centos-release | |
#get system info | |
$hostnamectl | |
#get kernel | |
$uname -a | |
$yum info kernel -q | |
#get installed package (i.e. filter to only postgresql packages) | |
$sudo yum list installed | grep postgresql | |
#List Installed Packages with Rpm | |
$sudo rpm -qa | grep postgresql | |
####################################################################################################### | |
#vnc remote to ubuntu | |
Installing the Desktop Environment and VNC Server | |
sudo apt update | |
sudo apt install xfce4 xfce4-goodies | |
sudo apt install tightvncserver | |
vncserver//set a VNC access password | |
vncpasswd//change a VNC access password | |
vncserver -kill :1 | |
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak //Before you modify the xstartup file, back up the original | |
//Now create a new xstartup file and open it in a text editor, such as nano: | |
nano ~/.vnc/xstartup | |
//Then add the following lines to the file: | |
#!/bin/bash | |
xrdb $HOME/.Xresources | |
startxfce4 & | |
//Save and close the file after adding these lines. If you used nano, do so by pressing CTRL + X, Y, then ENTER. | |
chmod +x ~/.vnc/xstartup//To ensure that the VNC server will be able to use this new startup file properly, you’ll need to make it executable: | |
//Then restart the VNC server: | |
vncserver -localhost //Notice that this time the command includes the -localhost option, which binds the VNC server to your server’s loopback interface. This will cause VNC to only allow connections that originate from the server on which it’s installed. | |
//In the next step, you’ll establish an SSH tunnel between your local machine and your server, essentially tricking VNC into thinking that the connection from your local machine originated on your server. This strategy will add an extra layer of security around VNC, as the only users who will be able to access it are those that already have SSH access to your server. | |
ssh -L 59000:localhost:5901 -C -N -l sammy your_server_ip //Create an SSH connection on your local computer that securely forwards to the localhost connection for VNC. You can do this via the terminal on Linux or macOS with the following ssh command: | |
//https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04 | |
####################################################################################################### | |
#GUI Install a Desktop Environment/GUI in Ubuntu Server | |
1-sudo apt update && apt upgrade | |
2-install desktop environment(one of these): | |
2-sudo apt-get install xfce4-session xfce4-goodies | |
2-sudo apt install ubuntu-mate-desktop | |
2-sudo apt install lxde | |
2-sudo apt install kde-plasma-desktop | |
2-For the vanilla GNOME experience | |
2-sudo apt install vanilla-gnome-desktop vanilla-gnome-default-settings | |
2-sudo apt install ubuntu-desktop | |
2-sudo apt install ubuntu-mate-core | |
2-sudo apt install xubuntu-core | |
3-display manager | |
3-sudo apt install lightdm | |
4-Setting Up LightDM | |
4-start the LightDM service with systemctl | |
4-sudo systemctl start lightdm.service | |
4-start the LightDM service using the service utility | |
4-sudo service ligthdm start | |
5-Remove GUI From Ubuntu Server | |
5-sudo apt remove [display-manager] [desktop-environment] | |
5-Reboot the system and log back in. | |
5-Finish by removing orphaned or unnecessary dependencies with autoremove | |
5-sudo apt autoremove ubuntu-desktop | |
5-sudo systemctl stop lightdm.service | |
5-sudo apt autoremove lightdm | |
####################################################################################################### | |
#environment setup for grails on ubuntu 9.10 | |
#!/bin/bash | |
#environment setup for grails on ubuntu 9.10 | |
#use the source "$ source env.sh" | |
export GRAILS_HOME=/home/tim/programs/grails-1.3.1 | |
export PATH=$PATH:$GRAILS_HOME/bin | |
export JAVA_HOME=/usr/lib/jvm/default-java | |
####################################################################################################### | |
#Create Image drawable for all resolutions | |
if [ $# -eq 0 ]; then | |
echo "No arguments supplied" | |
else if [ -f "$1" ]; then | |
echo " Creating different dimensions (dips) of "$1" ..." | |
mkdir -p drawable-xxhdpi | |
mkdir -p drawable-xhdpi | |
mkdir -p drawable-hdpi | |
mkdir -p drawable-mdpi | |
if [ $1 = "ic_launcher.png" ]; then | |
echo " App icon detected" | |
convert ic_launcher.png -resize 144x144 drawable-xxhdpi/ic_launcher.png | |
convert ic_launcher.png -resize 96x96 drawable-xhdpi/ic_launcher.png | |
convert ic_launcher.png -resize 72x72 drawable-hdpi/ic_launcher.png | |
convert ic_launcher.png -resize 48x48 drawable-mdpi/ic_launcher.png | |
rm -i ic_launcher.png | |
else | |
convert $1 -resize 67% drawable-xhdpi/$1 | |
convert $1 -resize 50% drawable-hdpi/$1 | |
convert $1 -resize 33% drawable-mdpi/$1 | |
mv $1 drawable-xxhdpi/$1 | |
fi | |
echo " Done" | |
else | |
echo "$1 not found." | |
fi | |
fi | |
####################################################################################################### | |
# strip non-existent files from monodevelop project file | |
#!/bin/bash | |
#strip non-existent files from monodevelop project file | |
projectFile=$1 #first arg should be the .mdp file to process | |
if [ "$1" == "" ] | |
then | |
echo "usage: $0 project.mdp" | |
exit 1 | |
fi | |
#set IFS to allow processing of files with spaces. | |
#ref http://tldp.org/LDP/abs/html/internalvariables.html | |
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html | |
IFS=$(echo -en "\n\b") | |
for f in `grep '<File' "$projectFile" | perl -pe 's|.*name="(.*?)".*|\1|'` | |
do | |
if [ ! -e "$f" ] | |
then | |
echo "'$f' doesn't exist, removing from project..." | |
escapedFile=`echo $f | sed -e 's/\//\\\\\//g'` | |
sed -i "/$escapedFile/d" $projectFile | |
fi | |
done | |
echo "done." | |
####################################################################################################### | |
# ubuntu install | |
#binary format file | |
chmod +x ~/downloads/filename.bin | |
sudo ~/downloads/filename.bin | |
#debian package format file | |
sudo dpkg -i filename.deb | |
####################################################################################################### | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment