How To Find Last Login on Linux?
To find the last login on Linux, use the “last”, “lastlog”, “/var/log/auth.log”, “who” and “lastb” commands that display username, terminal, date, and time.
To find the last login on Linux, use the “last”, “lastlog”, “/var/log/auth.log”, “who” and “lastb” commands that display username, terminal, date, and time.
To install the “tar.gz” files using sudo, extract the files, configure the binaries, then compile them, and lastly install the executable using sudo in Linux.
The “random.choice()” and “random.choices()” functions are used in Python to select random items from single or multiple lists or sets.
To print the simple array or numpy array the “print()” method and “for loop” method are used in Python. The “numpy.array()” function creates the numpy array.
To find the max int, the “sys.maxsize()” and “np.iinfor()” functions are used in Python. The “~sys.maxsize” is used to find the minimum integer.
To resolve ConnectionError in Python, various fixes are used such as checking the URL, using a retry object, try-except, and maintaining a stable connection.
To get timestamps in Python, the “datetime”, “calendar”, and “time” modules are used. The “datetime” module can be used to convert timestamps into DateTime.
To display the images in Python, the “Pillow” module, the “OpenCV” module, the “Scikit-Image” module, the “Matplotlib” module, and the “Tensorflow” are used.
The “random.random()” function and “random.uniform()” function is used in Python to generate the random float number within the specified range.
In Python, the square brackets[], np.empty() function, and list comprehension method are used to initialize or create an array.
To check if a file exists at the given path the “os.path.exists()” function, “os.path.isfile()” function, and “pathlibPath.exists()” function is used in Python.
To create the range of float numbers, the “np.arange()” function, “np.linspace()” function, list comprehension method, and Yield keyword are used in Python.
The Python “range()” function is used to generate the sequence of numbers from the specified starting value to stopping positions with a step size.
Load average is the measure to determine the processes running or waiting to be run on the CPU. Three different methods can find the load average.
To run the getent command in Linux, follow the general syntax “getent [Options] [Database] [Key]”. It finds the information from the computer’s databases.
Ubuntu offers the “.bashrc”, “.profile”, and “/etc/environment” files to add a path to the PATH environment variable permanently.
To find and change the MAC address, the ifconfig command, ip command, and “/sys/class/net/*/address” file are used in the system.
To install the GNOME disks utility on Ubuntu, use the command “sudo apt install gnome-disk-utility” on your system. Read this post for more details on it.
The passwd command is used by following the general syntax of the “passwd [Options] [User name]” to set and change the password of user accounts.
The Xmax scan can be performed using the nmap command in the system. This scan displays the status of the ports of the target machine.
To enable and disable the root user account in Ubuntu, utilize the “sudo -i” and “sudo -s”, “usermod”, “passwd” commands, and “sshd_config” files.
The “/dev/null” is a powerful tool in Linux that allows users to discard unwanted data, suppress error messages, make files disappear, and many more.
To view the contents of the ZIP archive in Linux, “zmore”, “zcat”, “zip, and unzip”, “Vim editors”, and “7z Achiever” are utilized.
To see the rsync command progress, either use the “–progress” option of the rsync command or pipe the rsync command with “pv -lep”.
To copy the files from the remote to the local machine using the SCP, run the command “scp [user@SRC_HOST:]file1 hostmachine_loation”.
Top 5 media servers for Linux in 2023 are OSMC, Plex, Subsonic, Gerbera, and Madsonic. They are all feature-rich and equipped with all the basic functionalities.
To implement the for each line operation on a file, the for loop is used in Bash scripting. This can be used to read each line of a file.
To change the MTU size instantly in Linux, the ip, and ifconfig commands and to make them permanently make changes in the network configuration file.
To increase the swap space in Linux, we can create a new swap file or partition. Both methods are explained in detail in the blog.
To fix the “Linux read-only file system” error, repair the filesystem by using the “sudo fsck -f [filesystem path]” or “Disk” application via GUI.
To fix the “rtnetlink answers: file exists”, remove the duplicate gateway by commenting it from the network file or flush the previous name.
To fix the “tar: removing leading ‘/’ from member names”, users can utilize the “-C” before the path or “P” to use the absolute path.
To fix the “this kernel requires an x86 64 cpu” error, ensure that the machine supports the 64-bit operating system or install the 64-bit version.
To fix it, ensure the version of the VirtualBox 5 or above is installed. Secondly, the guest additions are also installed on the host OS.
To install Portainer CE with Docker-Compose, install the Docker, Docker-Compose, and then set up the Portainer CE in that directory
To secure the SSH server in Ubuntu 22.04, open the configuration file of the SSH by running the command “sudo nano /etc/ssh/sshd_config” in the terminal.
To set the “JAVA_HOME” variable in Ubuntu, assign the path of the “javac” package to the JAVA_HOME variable in the bashrc file.
The chmod 777 means that all the file users, including the owner, group members, and the other users, can perform the reading, writing, and execution.
The “libstdc++6” is a dependency package of the GCC compiler, and “libstdc++.so.6” is the symbolic link that points to the GCC path.
To sort the pandas DataFrame by index in ascending or descending order, the “df.sort_index()” function is used in Python.
To convert the NumPy array to pandas DataFrame, the “pandas.DataFrame()” function and “pd.DataFrame.from_records()” function is used in Python.
In Python, first, the “cv2.imread()” function reads an image. After that, the “cv2.imshow()” function shows the image that is read by the “cv2.imread()”.
To convert a Dictionary to Pandas DataFrame, the “pd.DataFrame.from_dict()”, “pd.DataFrame()”, and “dict.items()” with “pd.DataFrame()” functions are used.
To completely uninstall Python from windows, you can use the “del” keyword from the “CMD” terminal or the “Add or Remove” setting from the control panel.
To check the Python version on windows, the “python -V”, sys.version, and Python_version() function is used. For Linux, the “python3 –version” command is used.
To export pandas DataFrame to a “csv“ file, the “df.to_csv()” function is used in Python. We can export specific columns of DataFrame into a csv file.
CentOS / RHEL offers the “clean all” command to clean the entire YUM cache, including “metadata ”, “package headers”, and “packages” from the system.
CentOS offers the “rpm -ql
CentOS offers the “yum” package manager to install the telnet via the “sudo yum install telnet” command. To configure it, enable the “telnet.socket” services.
CentOS offers the “firewall-cmd –permanent –add-port=80/tcp” command to open a port in the system. For this, configure the firewall to allow traffic.
CentOS offers the “YUM” to install a specific version of an RPM package on a system. For this, specify the “package name” and the “version”.
CentOS / RHEL offers the “sysctl” configuration file and “kernel” module to disable IPv6 in the system. For this, setting the disable_ipv6 parameter to 1.
CentOS offers the “ntpdate” command with the “ntpd” service to synchronize the NTP server forcefully. It sets the system time with the time of the NTP server.
To configure Docker to use a proxy, set the proxy information in the Docker daemon configuration file or pass the proxy information as environment variables.
Linux offers the “taskset” command to set or retrieve the CPU affinity of a running and a new process or thread in the operating system.
Linux offers the “echo “Body” | mailx -a attachment.pdf -s “Subject” [email protected]” command to send and receive email messages.
Linux offers the “sudo mkfs.xfs
Linux offers the “chmod” command with the “x” permission to make a Bash script executable. Also, you can set permission using the octal numbers.
Linux offers the “quotes”, “backslashes”, and “tab-completion” methods to read a filename with spaces in a specified directory.
To show the PATH of an environment variable, execute the “echo”, “cat”, “env”, “set”, and “printenv” commands with the “PATH” variable.
Linux offers the “sshpass -p [password] ssh [user]@[host]” command to connect to the remote host using a non-interactive SSH login.
The “utmp”, “wtmp”, and “btmp” files store the info of currently logged-in users, historical logs of all logins and logouts, and the failed login attempts.
Ubuntu offers the “hosts” file to map the hostnames to IP addresses. Ubuntu’s default location of the hosts file is “/etc/hosts”.
To enable any service, use the “sudo systemctl enable service_name” and to disable any service, use the command “sudo systemctl disable service_name”.
Linux offers “mount”, “df”, “cat /proc/mounts”, “lsblk”, and “findmnt” commands to check the mounted filesystem along with the mount point.
To mount the exFAT drive on Ubuntu Linux, create a mount point and specify the drive name. Lastly, use the mount command to mount it.
Linux offers the “sudo gpasswd -d
Linux offers the “history” command with the “c” option to clear the bash history. It removes all the records of previously entered commands in the terminal.
CentOS / RHEL offers the “clean all” command to clean the entire YUM cache, including “metadata ”, “package headers”, and “packages” from the system.
The absolute path gives the exact location of a file or directory, while the relative path refers to the file and directory in the current working directory.