How to create or delete user in Linux

  • To create a new user named joe:
$ sudo useradd joe

The above command does not create a home directory for the new user.

  • To create a new user named joe and create a home directory for him:
$ sudo useradd -m joe
  • To delete a user named joe:
$ sudo userdel joe

The above command does not remove the files owned by the user.

  • To delete a user named joe and remove all the files owned by him:
$ sudo userdel -r joe

Tried with: Ubuntu 16.04

Advertisements

How to delete file from Audacious

The ability to delete a music file directly from Audacious can be useful. However, the version of Audacious that ships with latest Ubuntu does not have this feature. Thankfully, it has been implemented as a plugin and ships with Audacious 3.5.2.

To remove your Audacious and install the latest Audacious from PPA:

$ sudo apt-get remove audacious
$ sudo add-apt-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install audacious

To turn on the feature to delete files, enable Files -> Settings -> Plugins -> General -> Delete Files. Right-click on a file in the playlist and choose Services -> Delete Selected Files. The files will be moved to Trash, so you can recover them later if you want.

Tried with: Audacious 3.5.2 and Ubuntu 14.04

How to delete lines containing search string using sed

To remove all the lines in a file which has a certain search string can be accomplished easily using sed.

For example, to remove all the lines in in.txt with the text foobar:

$ sed '/foobar/d' in.txt > out.txt

If you would like the line removal to be performed in-place on the input file:

$ sed -i '/foobar/d' in.txt

Tried with: Sed 4.2.2 and Ubuntu 14.04

How to delete elements of mesh in Blender

Blender can be used to edit a mesh by deleting vertices, edges or faces from it.

1. Switch to Edit Mode. Switching the Mode can be done from the dropdown in the bottom bar.

2. Depending on whether you want to delete a vertex, edge or face, choose the corresponding Select Mode. These buttons are placed a few buttons to the right of the Mode dropdown. For example, to delete a vertex click the Vertex select mode button.

3. To choose the elements of the mesh you want to delete, click on them using the right mouse button. Keep the Shift key pressed, if you want to select many elements. You can only select the elements of the select mode you picked. For example, in Vertex select mode you can only select vertices.

4. After you have chosen the elements, press the Delete key. A context menu comes up and you can choose what you want to delete: vertices, edges, faces or all. For example, if you chose a vertex, the dialog is asking whether you want to delete that vertex, or the edges incident to that vertex or the faces incident to that vertex or all of the above. Select what you want and those elements will be deleted from the mesh.

Tried with: Blender 2.62 and Ubuntu 12.04 LTS

Delete pages from a DjVu document

Deleting one or more pages from a DjVu document can be done using the DjVu multipage document manipulation utility. This is the executable djvm.exe that ships with the DjVuLibre package.

The -d option can be used to delete a single page from the document. However, djvm does not accept multiple pages or a range of pages to delete. To achieve this, invoke djvm multiple times using the looping features of your shell. The example below is for PowerShell.

Tried with: DjVuLibre 3.5.25.3

How to delete all lines of file in Vim

Problem

To delete all the lines of a file that is open in Vim.

Solution

  1. Type gg to move the cursor to the first line of the file, if it is not already there.
  2. Type dG to delete all the lines.

Deleting all the lines of a file is not a frequently used operation. So, I need a command that is easy to recall, even though it is not used much. I find dG easy to remember since I frequently use dd to delete a line, and also gg and G, which move the cursor to the first and last line of the file respectively.

Tried with: Vim 7.3