Linux FAQ¶
Click on the links in the headings for more information.
Find files in a terminal¶
find / -type f -iname "*postgis-2.0.0*"
where:
./indicates that you want to search in the current directory. This can be replaced with the directory you want to start your search from.fcan be replaced with d if you’re searching for a directory instead of a file-inamecan be replaced with -name if you want the search to be case sensitive*in the search term can be omitted if you don’t want the wildcards in the search. In this case,*indicates that any number of different characters could be present where the*is located in the string. See this link for more information on wildcards
The grep command can be used to simplify things further:
find . | grep -i "screen"
where -i indicates the search term is case insensitive. see this link for further
details about the grep command.
Change file permissions¶
Change permissions :
chmod -R 755 your_directory
| Value | Description |
|---|---|
| 755 | (rwxr-xr-x) The file’s owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users. |
tar/untar or zip/unzip¶
Compress:
tar -zcvf archive_name.tar.gz directory_to_compress tar -jcvf archive_name.tar.bz2 directory_to_compress zip -r archive_name.zip directory_to_compressUncompress:
tar -zxvf archive_name.tar.gz tar -jxvf archive_name.tar.bz2 -C /tmp/extract_here/ unzip archive_name.zip
Search for files in directory¶
find / -name 'program.c'
Find size of directory¶
du -sh folder du -h -d1 folder # Only the top level directories.
Print all environmental variables¶
printenvTo show a list including the “shell variables”:
( set -o posix ; set ) | less
Download file from the internet¶
wget http://www.openss7.org/repos/tarballs/strx25-0.9.2.1.tar.bz2
Restart network manager (Ubuntu 16.04)¶
sudo systemctl restart NetworkManager # or sudo service network-manager restart
- This is useful if you VPN disconnects and you get the following error when
- trying to connect.
psam012@pc:~$ ssh psam012@bioeng10.bioeng.auckland.ac.nz ssh: Could not resolve hostname bioeng10.bioeng.auckland.ac.nz: Temporary failure in name resolution
GUI utility to mount remote filesystems over SSH¶
Older versions of Ubuntu (<11.10)¶
By default the GVFS in GNOME supports SSH connections. Click on the nautilus icon (the folder with the house on it) it will launch the file manager.
Then go to File -> “Connect to server”:
Paste in the following:
| Sever: | bioeng10.bioeng.auckland.ac.nz |
| Folder: | /hpc/upi |
| UserName: | upi |
Click connect and put in your password (ask it to forget immediately for now)
This will mount the remote SSH server in a folder you can access from the file manager. If you need to access the mount in the command line it’s in .gvfs.
You can also mount it in Nautilus. Just hit CTRL+L and in the address bar
type: ssh://server-ip/somepath/
Newer versions of Ubuntu (>11.10)¶
press Alt+F2 and type nautilus-connect-server as shown below.
Adding menu items in gnome ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^