Professional Documents
Culture Documents
The items in the square brackets are discretionary, but the main obligatory
argument is “filesys”. filesys is the name of a device document (i.e., a record
that the system uses to execute admittance to a physical device), for
example, /dev/hda3, the third segment on the primary HDD, or/dev/fd0, the
principal floppy disk. It can likewise be the mount point (i.e., where it is
joined to the system) for the new file system.
The most commonly used option is “-t”, which is utilized for specifying the
type of file system to be created. If this option is not used, the default
filesystem created will be ext2 (second extended file system) from the other
types of file systems that can be created like ext3, minix, msdos, vfat and
xfs.
The -V option is used to produce verbose output, and also includes all file
system-specific commands that are executed. By specifying this option more
than once, the execution of any file system-specific commands can be
prevented.
The “-c” option, will check the storage device for bad blocks before creating
the file system, and the “-l” option, will read the bad blocks list from a file
whose name follows it.
“fs-options” stand for file system-specific options that are to be passed to the
real file system creation program (i.e., the program for which mkfs is serving
just as a front end).
In the modern era, the way of utilizing mkfs is to type “mkfs.” and then the
name of the file system you wish to create.
Now, in order to see all the file systems offered by the “mkfs” command, hit
the Tab key twice.
The list of all available file systems available in the Linux distribution being
used will be displayed in the terminal window. The screenshot is from
Ubuntu 18.04 LTS. Other distributions may have more or fewer options:
8. Lastly, execute the following command for ejecting the drive when finished.
sudo eject /dev/sdb
Now, We have successfully formatted the USB storage device and have also
created a file system with a partition.
fsck Command
The fsck (File System Consistency Check) Linux utility checks filesystems for
errors or outstanding issues.
One method to locate the disk you want to scan is to list the filesystem disks
with the df command:
df -h
The tool prints the data usage on your system and filesystems. Take note of
the disk you want to check with the fsck command.
To view partitions for your first disk, for example, use the following command:
sda is how Linux refers to your first SCSI disk. If you have two, the second
would be sdb, and so on.
In our example, we got one result since there was only one partition on this
virtual machine. You will get more results if you have more partitions.
The disk name here is /dev/sda and then the number of partitions is shown in
the Number column. In our case, it is one: sda1.
Before you can run a disk check with fsck, you need to unmount a disk or
partition. If you try to run fsck on a mounted disk or partition, you will get a
warning:
The above example shows the output for a clean disk. If there are multiple
issues on your disk, a prompt appears for each one where you have to confirm
the action.
The exit code the fsck utility returns is the sum of these states:
mount /dev/sdb
The output prints what would happen but does not perform any actions.
This way, you say “yes, try to fix all detected errors” without being prompted
every time.
If no errors are found, the output looks the same as without the -y option.
For example:
The scan will perform all five checks to search for corruptions even when it
thinks there are no issues.
fsck -AR
To show you the difference, we will run fsck on sdb while it is mounted, and
then when we unmount it.
Note: To remove the first title line of the fsck tool “fsck from util-linux 2.31.1”
use the -T option.
1. To do so, power on or reboot your machine through the GUI or by using the
terminal:
sudo reboot
2. Press and hold the shift key during boot-up. The GNU GRUB menu appears.
4. Then, select the entry with (recovery mode) at the end. Let the system load
into the Recovery Menu.
In case the utility found an error while the check was in process, it will not try
to fix anything if interrupted. You can rerun the check next time and let it
finish.
Option Description
Try to repair filesystem errors automatically. There will be no prompts, so use it with
-a
caution.
-f Force fsck to check a filesystem. The tool checks even when the filesystem appears to
Option Description
be clean.
Lock the device to prevent other programs from using the partition during the scan
-l
and repair.
Do not check mounted filesystems. The tool returns an exit code 0 when a filesystem
-M
is mounted.
Do a dry run. The output prints what the fsck would do without executing any actions.
-N
The warning or error messages are printed as well.
Use to run a scan on multiple filesystems in parallel. It can cause issues, depending on
-P
your setup. Use with caution.
-R Tell the fsck tool not to check the root filesystems when you use the -A option.
Specify which filesystems type(s) to check with fsck. Consult the man page for
-t
detailed information.
-V Verbose output.
Syntax:
mount -t type device dir
Other forms:
mount [-l|-h|-V]
mount -a [-fFnrsvw] [-t fstype] [-O optlist]
mount [-fnrsvw] [-o options] device|dir
mount [-fnrsvw] [-t fstype] [-o options] device dir
These commands tells the Kernel to attach the filesystem found at device to
the dir.
Note:
If you leave the dir part of syntax it looks for a mount point in /etc/fstab.
You can use –source or –target to avoid ambivalent interpretation.
mount --target /mountpoint
/etc/fstab usually contains information about which device is need to be
mounted where.
Most of the devices are indicated by files like /dev/sda4, etc. But it can be
different for certain filesystems
When an interactive shell that is not a login shell is started, Bash reads and
executes commands from ~/.bashrc, if that file exists. This may be inhibited
by using the --norc option. The --rcfile file option will force Bash to
read and execute commands from file instead of ~/.bashrc.
Invoked non-interactively
Bash attempts to determine when it is being run with its standard input
connected to a network connection, as when executed by the remote shell
daemon, usually rshd, or the secure shell daemon sshd. If Bash determines it is
being run in this fashion, it reads and executes commands from ~/.bashrc, if
that file exists and is readable. It will not do this if invoked as sh. The --
norc option may be used to inhibit this behavior, and the --rcfile option
may be used to force another file to be read, but neither rshd nor sshd generally
invoke the shell with those options or allow them to be specified.
If Bash is started with the effective user (group) id not equal to the real user
(group) id, and the -p option is not supplied, no startup files are read, shell
functions are not inherited from the environment,
the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in
the environment, are ignored, and the effective user id is set to the real user id.
If the -p option is supplied at invocation, the startup behavior is the same, but
the effective user id is not reset.
Installing packages
The APT is the tool, commonly used to install packages, remotely from the
software repository.
In short it’s a simple command based tool that you use to install
files/softwares.
Complete command is apt-get and it’s the easiest way to install
files/Softwares packages.
This easy tools informs you about packages that are currently being installed
and also it informs you about the packages that are available in repositories.
apt-get install ${packagename}
To remove/uninstall any software, just use remove
apt-get remove ${packagename}
The software packages are somewhere in the online repositories, APT handles a
local database on the user’s hard drive that contains informations about the
available packages and where they are located.
So when the types the command, apt-get install conky, the APT will start finding
the package named conky in the database and will install conky once user types
‘y’ (yes).
To get the all newly uploaded packages on the repositories, user need to update
APT regularly.
To update APT database:
apt-get update
To update the APT database and also upgrade the security updates and patches
that might be available for some installed softwares, users may do it at once just
by using the commands like this:
apt-get update; apt-get upgrade
Printers use a description file with one or more driver ("filter") programs that
communicate with the printer through a "backend" program.
CUPS currently uses PPD (PostScript Printer Description) files to describe the printer
and driver programs needed, some of which come with CUPS while others come with
your operating system or Linux distribution.
Backends are specified using a URI (Universal Resource Identifier) where the URI
scheme is the backend name, e.g., "ipp://11.22.33.44/ipp/print" specifies the "ipp"
backend - like PPD files, some backends come with CUPS while others come with
your operating system.
Classes are associated with one or more printers and are typically used to distribute
print jobs amongst a group of printers or provide redundancy or high availability
when printing.
Print jobs sent to a class are forwarded to the next available printer in the class.
Managing Printers
The lpadmin command is used to create, modify, or delete a printer. The -p option specifies
a printer to create or modify:
The lpadmin accepts several additional options after -p printername when adding or
modifying a printer:
-D "description"
Sets the description of the printer which is often shown instead of the printer name, for
example "HP LaserJet".
-E
Enables the printer and accepts new print jobs.
-L "location"
Sets the location of the printer, for example "Conference Room".
-m model
Sets the printer driver using the model name.
-o option=value
Sets the named option.
-v device-uri
Sets the URI for the printer.
lpadmin -x printername
lpinfo –m
Each line contains the driver name followed by its description, for example:
The everywhere driver is used for nearly all modern networks printers sold since about
2009. For example, the following command creates a destination for a printer at IP address
11.22.33.44:
Printer Options
The lpadmin command allows you to set various options for a printer:
-o cupsIPPSupplies=false
Turns off IPP supply level reporting for a printer.
-o cupsSNMPSupplies=false
Turns off SNMP supply level reporting for a printer.
-o name=value
Sets the default value for the named PPD option. For example, -o PageSize=Legal sets the
default page size to US Legal.
-o printer-error-policy=name
Sets the policy for errors such as printers that cannot be found or accessed, don't support the
format being printed, fail during submission of the print data, or cause one or more filters to
crash:
abort-job
Aborts the job on error.
retry-job
Retries the job at a future time
retry-current-job
Retries the current job immediately.
stop-printer
Stops the printer on error.
-o printer-is-shared=true/false
Enables/disables per-printer sharing.
-o printer-op-policy=name
Sets the operation policy associated with the printer.
-u allow:{user|@group}{,user|,@group}*
-u allow:all
-u deny:{user|@group}{,user|,@group}*
-u deny:none
Sets user-level access control for the printer. The allow: list defines a whitelist of users and
groups while the deny: list defines a blacklist of users and groups.
Printer Sharing
CUPS supports sharing of printers with other computers and mobile devices.
Two cupsctl options control the general printer sharing features:
--share-printers
Enables sharing of printers with other computers and mobile devices on your local network.
--remote-any
Expands printer sharing to any network that can reach your server.
Once you have enabled printer sharing, you then must select which printers will be shared
using the lpadmin command and the -o printer-is-shared=true option.
For example, to share two printers ("foo" and "bar") on the local network, run the following
commands:
cupsctl --share-printers
lpadmin -p foo -o printer-is-shared=true
lpadmin -p bar -o printer-is-shared=true
Managing Classes
The lpadmin command is used to create, modify, or delete a class.
The -c option specifies a class to create or modify and is combined with the -p option:
lpadmin -x classname
The printing system log files track the activity of the scheduler, printer drivers, and backends.
If problems occur and the log files do not provide sufficient details to diagnose the problem, you
can enable debug logging using the cupsctl command:
cupsctl --debug-logging
To disable debug logging, run the same command with the --no-debug-logging option:
cupsctl --no-debug-logging
Details
Samba Port No 445
Folders related to Samba /etc/samba /usr/lib/samba /usr/share/doc/samba-
x.x.x /usr/log/samba
Samba Configuration file /etc/samba/smb.conf
Starting, stopping and restarting /etc/init.d/smb {start | stop | restart} (Red hat,
Samba server Debian,SUSE)
/etc/init.d/samba {start | stop | restart} (Ubuntu)
File-system CIFS
Driver file /sbin/mount.cifs
Kernel Module cifs.ko
GUI Configuration tool System-config-samba ( Red hat, Ubuntu)
Web Configuration tool SWAT
SWAT Port No 901
Service Part of xinetd or inetd
Swat documents folder /usr/share/swat
Installation
Samba can be installed using the following commands.
For installing Samba on a Fedora or any other Redhat based machine, use
the following command:
If you want to install Samba from a source package, you can download it
from the following link:
http://samba.org/samba/download/
Installing system-config-samba
system-config-samba is a GUI tool which is used to configure Samba server
in a Linux machine with GUI.
SWAT
SWAT is web based configuration tool which helps to configure the Samba
server from a remote location.
It is often used to configure complex smb.conf files.
SWAT uses port no 901 to access the Samba server.
Installation
SWAT can be installed on a Redhat based OS using the following command:
Now you can browse through the page to configure various options such as
adding shares and adding printers.
Hence we need to create Samba users for accessing the shares from a Samba
server.
Accessing the Samba share from a Windows Client
Accessing the Samba share directly
Goto Start menu -> Run
Enter the ip-address of the Samba server.
Now a Windows explorer will open showing the shared folders from the
Samba server
Now goto the folder showing with which it has been shared in the server
If you want to browse through the network
Goto Start Menu -> Computer, A window will open, Click on Network. It
shows all the network computers, including your Samba server, connected to
your PC. Now you can browse through the network.
If you want to browse through the network
Goto Gnome menu-> Places -> Network
A windows will open up showing “Windows Network”
Double click on “Windows Network” to browse through the windows
network which contains Samba servers also
Click on the Samba server by identifying using the hostname in the list
To mount the share using Command line interface
Use the following command:
$ sudo mount -t cifs /<ip-address>/<share-
name>/ /<mount-point> -o user=<username>
To mount the share at every boot
Add the following line to the /etc/fstab file
Logging in Samba
Logs related to Samba can be found in the folder /var/log/samba.
When we try to access the Samba share from another machine it creates a
new file with the file name in the following format.
/var/log/samba/log.<hostname>
Associated services
Some useful commands related to Samba
findsmb
findsmd can be used to find the machines in the network which respond to
smb queries.
testparm
testparm command can be used to test the Samba configuration in the
server.
smbtree
This command can be used to list all the Samba and Windows file servers in
the network.
https://cssoss.wordpress.com/2010/05/25/samba-sharing/#:~:text=Configuring%20the
%20shared%20printer%20on%20a%20Linux%20Client%20with%20Gnome,
%E2%80%9CWindows%20Printer%20via%20Samba%E2%80%9D.