Home » Linux Basics (page 3)

Linux Basics

Linux: How To Empty a Directory

How do I empty a directory (delete all files) under Linux / Unix without deleting directory itself? You can use the following commands: [a] rm command – Delete one or more files or directories. [b] find command – Find and delete all files from a specific directory. Linux Empty Directory Using the rm Command Consider the following directory structure: /tmp/ | |------foo/ |---file1 |---file2 …

Read More »

The 10 most useful Linux commands

Maybe the command line isn’t your favorite place to hang out, but to be an effective Linux admin, you need to be able to wield a few essential commands. These 10 are guaranteed to simplify your Linux admin life — and he explains why. I understand that many of you don’t want to use the command line in Linux (or …

Read More »

DOS-to-UNIX file conversion

Using Perl: # WARNING! For UNIX only! Do not use with ActivePerl in MSYS shell on Windows! # (Returns error message and file is deleted.) perl -pi -e 's/\r\n/\n/g' filename Using sh or bash: Works fine even in MSYS shell on Windows. #tr -d '\r' < original_filename > new_filename (Note that the “<” and “>” must be typed for this command to work). …

Read More »

Linux: Restart Nginx WebServer

How do I restart nginx web server under Linux? To restart nginx web server use any one of the following command as a root user: # /etc/init.d/nginx restart However, recommed way is as follows which should work with any Linux distribution : # nginx -s reload OR # /usr/local/nginx/sbin/nginx -s reload Originally posted 2016-03-10 02:57:42.

Read More »

How to delete a file

How do I delete a file under Linux  operating system? To remove a file or directory in Linux use the rm command. rm command syntax rm (short for remove) is a Unix / Linux command which is used to delete files from a filesystem. Usually, on most filesystems, deleting a file requires write permission on the parent directory (and execute …

Read More »

Linux: Bash Find Matching All Dot Files

A dot-file is generally any file whose name begins with a full stop. In Linux it is also called as hidden file. How do I list all dot files in my home directory? You can use the ls command to list all dot files in your current directory:   ls .* Sample outputs: .bash_history .bash_profile .bashrc .lesshst .profile .viminfo .: …

Read More »