Main Page

From Newroco Tech Docs
Jump to navigationJump to search

Welcome to the Docs Wiki hosted by newroco

Please use the newroco docs wiki style guide when formatting pages. The style guide also contains basic tips on wiki markup. You can get more help on using wikis from the User's Guide.

NB Some instructions documented on this server will reference sudo or visudo; while these are normally available as part of default installs, some server build templates for hosted servers may not include them, and if so they can be installed as a root user by:

apt-get install sudo

Current topics

Virtualisation

DatabaseBackupProcedure

SSHKeyAuth

SSH from Windows

SSH for multiple server management

Puppet

Creating a simple mail server

Nextcloud

Spreed.me

Joomla

PostgreSQL

>How to set up software RAID 1 on a running system ( Incl GRUB 2 configuration )

Popular commands

Some useful and therefore popular commands follow, with some commonly used options. Not a definitive list of either commands or options, but can refer to the individual command help files for other options by either adding a

--help

or using their manual

man <command>

or info page

info <command>

. Not all commands provide all (or any) type of additional documentation, and man/info commands and data in themselves need to be installed.

ls

This command lists the content of the current working directory or a specified directory, with various output options

ls -l

Returns the long form of the directory, useful for seeing whether files are shortcuts or when they were last changed

ls -lh

As above but returns file sizes in "h"uman readable format (kB, MB etc.)

ls -a

Shows hidden files (ones whose name starts with a "."). Can be combined with other switches above.

df

This shows how much "d"iskspace is "f"ree.

df -h

returns the info in "h"uman readable format

df -i

shows available inodes (index pointers) - can be useful when disk acts as if full but df -h shows space available

du

This command is like df but for directories.

du -hs *

probably the most common use. Returns the total space used by each subdirectory of the current working directory, useful for working out what's eating your disk space

ssh

For securely accessing remote servers

 ssh <username>@<server>

most common usage form. Some servers or firewalls may use a non-standard port number, in which case use -p<portnumber> (no space) after the ssh part. For more see:

tar

To create a tar.gz archive

tar -czf new-tar-file-name.tar.gz file-or-folder-to-archive

To extract from a tar archive

tar -xzf tar-file-name.tar.gz


grep

This is a powerful way to find stuff in files, particularly useful for tracking stuff down in logs, or in complex multi-aprt configuration files

grep -i <thething> <thefileorpathwithwildcards>

Finds all references, case "i"nsensitively, to the <thething> and returns them in a list within the line that contains them and the filename when searching multiple files

grep -iv <thething> <thefileorpathwithwildcards>

As above but in"v"erted, i.e. returns all lines that don't contain <thething>

grep -ic <thething> <thefileorpathwithwildcards>

Returns a "c"ount of the number of times <thething> occurs You can also take advantage of the "|" to pass output from one grep to another to refine the results e.g.

grep -i <thething> <thefileorpathwithwildcards> | grep -v "#" 

Would return all lines containing <thething> that have not got a comment marker (# often if not always used for commenting out lines in conf files, for example)

less & more

vi

cat

 # cat filename

is a quick and easy way to display a text file on CLI. Particularly useful for smaller files and when you want to grab a line to copy elsewhere

sudo

This is used anytime you need additional privileges on a system. It assumes you are not just logging in as the anonymous "root" user (which we disable ssh access to normally) nor that your account has root powers (not recommended). Generally used in the form

sudo <thecommandtorun>

find

Does what it says on the tin, finds stuff. Lots of options available such as finding files modified/accessed by time passed or on a date or date range. Simplest form and most common use is to find a file by name or part name using find <path> name <name or name+wildcard> e.g.

find / -name ttnsub*

How to delete files older than five days

find /path/to/files* -mtime +5 -exec rm {} \;